mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-19 01:31:34 +00:00
Updated Linux-only disk stats
Restore disk usage stats even when config.linuxDiskStats is off The said config will now only toggle the 'extended' stats which are disk usage of each directories within the uploads directory
This commit is contained in:
parent
ee443b5108
commit
19b4a5e217
@ -487,8 +487,8 @@ module.exports = {
|
||||
cacheControl: false,
|
||||
|
||||
/*
|
||||
Enable Linux-only disk stats in Dashboard's Statistics.
|
||||
This will use a combination of both "du" and "df" binaries.
|
||||
Enable Linux-only extended disk stats in Dashboard's Statistics.
|
||||
This will use "du" binary to query disk usage of each directories within uploads directory.
|
||||
Disabled by default as I personally found it to be very slow with +100k uploads
|
||||
with my ancient potato server.
|
||||
*/
|
||||
|
@ -41,6 +41,11 @@ const statsCache = {
|
||||
generating: false,
|
||||
generatedAt: 0
|
||||
},
|
||||
disk: {
|
||||
cache: null,
|
||||
generating: false,
|
||||
generatedAt: 0
|
||||
},
|
||||
albums: {
|
||||
cache: null,
|
||||
generating: false,
|
||||
@ -61,13 +66,6 @@ const statsCache = {
|
||||
}
|
||||
}
|
||||
|
||||
if (config.linuxDiskStats)
|
||||
statsCache.disk = {
|
||||
cache: null,
|
||||
generating: false,
|
||||
generatedAt: 0
|
||||
}
|
||||
|
||||
const cloudflareAuth = config.cloudflare && config.cloudflare.apiKey &&
|
||||
config.cloudflare.email && config.cloudflare.zoneId
|
||||
|
||||
@ -631,7 +629,7 @@ self.stats = async (req, res, next) => {
|
||||
}
|
||||
|
||||
// Disk usage, only for Linux platform
|
||||
if (config.linuxDiskStats && os.platform === 'linux')
|
||||
if (os.platform === 'linux')
|
||||
if (!statsCache.disk.cache && statsCache.disk.generating) {
|
||||
stats.disk = false
|
||||
} else if (((Date.now() - statsCache.disk.generatedAt) <= 60000) || statsCache.disk.generating) {
|
||||
@ -643,17 +641,20 @@ self.stats = async (req, res, next) => {
|
||||
|
||||
stats.disk = {
|
||||
_types: {
|
||||
byte: ['uploads', 'thumbs', 'zips', 'chunks'],
|
||||
byteUsage: ['drive']
|
||||
},
|
||||
drive: null,
|
||||
// We pre-assign the keys below to fix their order
|
||||
uploads: 0,
|
||||
thumbs: 0,
|
||||
zips: 0,
|
||||
chunks: 0
|
||||
drive: null
|
||||
}
|
||||
|
||||
// Linux-only extended disk stats
|
||||
if (config.linuxDiskStats) {
|
||||
// We pre-assign the keys below to fix their order
|
||||
stats.disk._types.byte = ['uploads', 'thumbs', 'zips', 'chunks']
|
||||
stats.disk.uploads = 0
|
||||
stats.disk.thumbs = 0
|
||||
stats.disk.zips = 0
|
||||
stats.disk.chunks = 0
|
||||
|
||||
const subdirs = []
|
||||
|
||||
// Get size of uploads path (excluding sub-directories)
|
||||
@ -726,6 +727,7 @@ self.stats = async (req, res, next) => {
|
||||
})
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
// Get disk usage of whichever disk uploads path resides on
|
||||
await new Promise((resolve, reject) => {
|
||||
|
Loading…
Reference in New Issue
Block a user