mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-18 17:21:33 +00:00
Updated
No longer initiate expired uploads check if config.uploads.temporaryUploadsInterval is not set. "yarn delete-expired" will now list names of the expired uploads too.
This commit is contained in:
parent
be7437d673
commit
968fd74676
@ -549,19 +549,21 @@ self.purgeCloudflareCache = async (names, uploads, thumbs) => {
|
||||
return results
|
||||
}
|
||||
|
||||
self.bulkDeleteExpired = async (dryrun) => {
|
||||
self.bulkDeleteExpired = async (dryrun, verbose) => {
|
||||
const timestamp = Date.now() / 1000
|
||||
const field = 'id'
|
||||
const fields = ['id']
|
||||
if (verbose) fields.push('name')
|
||||
const sudo = { username: 'root' }
|
||||
|
||||
const result = {}
|
||||
result.expired = await db.table('files')
|
||||
.where('expirydate', '<=', timestamp)
|
||||
.select(field)
|
||||
.then(rows => rows.map(row => row[field]))
|
||||
.select(fields)
|
||||
|
||||
if (!dryrun) {
|
||||
const values = result.expired.slice() // Make a shallow copy
|
||||
// Make a shallow copy
|
||||
const field = fields[0]
|
||||
const values = result.expired.slice().map(row => row[field])
|
||||
result.failed = await self.bulkDeleteFromDb(field, values, sudo)
|
||||
}
|
||||
|
||||
|
@ -246,8 +246,10 @@ safe.use('/api', api)
|
||||
logger.log('Cache control enabled without Cloudflare\'s cache purging')
|
||||
}
|
||||
|
||||
// Temporary uploads
|
||||
if (Array.isArray(config.uploads.temporaryUploadAges) && config.uploads.temporaryUploadAges.length) {
|
||||
// Temporary uploads (only check for expired uploads if config.uploads.temporaryUploadsInterval is also set)
|
||||
if (Array.isArray(config.uploads.temporaryUploadAges) &&
|
||||
config.uploads.temporaryUploadAges.length &&
|
||||
config.uploads.temporaryUploadsInterval) {
|
||||
let temporaryUploadsInProgress = false
|
||||
const temporaryUploadCheck = async () => {
|
||||
if (temporaryUploadsInProgress)
|
||||
@ -266,9 +268,8 @@ safe.use('/api', api)
|
||||
|
||||
temporaryUploadsInProgress = false
|
||||
}
|
||||
temporaryUploadCheck()
|
||||
|
||||
if (config.uploads.temporaryUploadsInterval)
|
||||
temporaryUploadCheck()
|
||||
setInterval(temporaryUploadCheck, config.uploads.temporaryUploadsInterval)
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ const self = {
|
||||
const dryrun = self.mode === 0
|
||||
const quiet = self.mode === 2
|
||||
|
||||
const result = await utils.bulkDeleteExpired(dryrun)
|
||||
const result = await utils.bulkDeleteExpired(dryrun, true)
|
||||
|
||||
if (quiet) return
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user