mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-19 01:31:34 +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
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bulkDeleteExpired = async (dryrun) => {
|
self.bulkDeleteExpired = async (dryrun, verbose) => {
|
||||||
const timestamp = Date.now() / 1000
|
const timestamp = Date.now() / 1000
|
||||||
const field = 'id'
|
const fields = ['id']
|
||||||
|
if (verbose) fields.push('name')
|
||||||
const sudo = { username: 'root' }
|
const sudo = { username: 'root' }
|
||||||
|
|
||||||
const result = {}
|
const result = {}
|
||||||
result.expired = await db.table('files')
|
result.expired = await db.table('files')
|
||||||
.where('expirydate', '<=', timestamp)
|
.where('expirydate', '<=', timestamp)
|
||||||
.select(field)
|
.select(fields)
|
||||||
.then(rows => rows.map(row => row[field]))
|
|
||||||
|
|
||||||
if (!dryrun) {
|
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)
|
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')
|
logger.log('Cache control enabled without Cloudflare\'s cache purging')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary uploads
|
// Temporary uploads (only check for expired uploads if config.uploads.temporaryUploadsInterval is also set)
|
||||||
if (Array.isArray(config.uploads.temporaryUploadAges) && config.uploads.temporaryUploadAges.length) {
|
if (Array.isArray(config.uploads.temporaryUploadAges) &&
|
||||||
|
config.uploads.temporaryUploadAges.length &&
|
||||||
|
config.uploads.temporaryUploadsInterval) {
|
||||||
let temporaryUploadsInProgress = false
|
let temporaryUploadsInProgress = false
|
||||||
const temporaryUploadCheck = async () => {
|
const temporaryUploadCheck = async () => {
|
||||||
if (temporaryUploadsInProgress)
|
if (temporaryUploadsInProgress)
|
||||||
@ -266,9 +268,8 @@ safe.use('/api', api)
|
|||||||
|
|
||||||
temporaryUploadsInProgress = false
|
temporaryUploadsInProgress = false
|
||||||
}
|
}
|
||||||
temporaryUploadCheck()
|
|
||||||
|
|
||||||
if (config.uploads.temporaryUploadsInterval)
|
temporaryUploadCheck()
|
||||||
setInterval(temporaryUploadCheck, config.uploads.temporaryUploadsInterval)
|
setInterval(temporaryUploadCheck, config.uploads.temporaryUploadsInterval)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ const self = {
|
|||||||
const dryrun = self.mode === 0
|
const dryrun = self.mode === 0
|
||||||
const quiet = self.mode === 2
|
const quiet = self.mode === 2
|
||||||
|
|
||||||
const result = await utils.bulkDeleteExpired(dryrun)
|
const result = await utils.bulkDeleteExpired(dryrun, true)
|
||||||
|
|
||||||
if (quiet) return
|
if (quiet) return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user