mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-18 17:21:33 +00:00
Updates
Got rid of caching of statistics. The previous implementation wasn't perfect, and too lazy to improve it.
This commit is contained in:
parent
8c3fb78135
commit
3e336e8c6d
@ -564,9 +564,6 @@ uploadsController.formatInfoMap = (req, res, user, infoMap) => {
|
||||
userid: user !== undefined ? user.id : null,
|
||||
timestamp: Math.floor(Date.now() / 1000)
|
||||
})
|
||||
|
||||
// Update last upload timestamp
|
||||
utils.lastUpload = Date.now()
|
||||
} else {
|
||||
utils.deleteFile(info.data.filename, req.app.get('uploads-set')).catch(console.error)
|
||||
existingFiles.push(dbFile)
|
||||
|
@ -9,11 +9,7 @@ const path = require('path')
|
||||
const perms = require('./permissionController')
|
||||
const sharp = require('sharp')
|
||||
|
||||
const utilsController = {
|
||||
lastUpload: Date.now(),
|
||||
lastStatsBuilt: 0,
|
||||
cachedStats: {}
|
||||
}
|
||||
const utilsController = {}
|
||||
|
||||
const uploadsDir = path.join(__dirname, '..', config.uploads.folder)
|
||||
const thumbsDir = path.join(uploadsDir, 'thumbs')
|
||||
@ -459,10 +455,6 @@ utilsController.stats = async (req, res, next) => {
|
||||
if (platform !== 'win32')
|
||||
system.loadavg = `${os.loadavg().map(load => load.toFixed(2)).join(', ')}`
|
||||
|
||||
// Return cached stats
|
||||
if (utilsController.lastStatsBuilt > utilsController.lastUpload)
|
||||
return res.json({ success: true, system, stats: utilsController.cachedStats })
|
||||
|
||||
const stats = {
|
||||
uploads: {
|
||||
count: 0,
|
||||
@ -506,8 +498,6 @@ utilsController.stats = async (req, res, next) => {
|
||||
if (user.permission === perms.permissions[p]) stats.users.permissions[p]++
|
||||
}
|
||||
|
||||
utilsController.cachedStats = stats
|
||||
utilsController.lastStatsBuilt = Date.now()
|
||||
return res.json({ success: true, system, stats })
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user