mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-18 17:21:33 +00:00
feat: console logs of temp uploads check ups
This commit is contained in:
parent
5d3ef6e566
commit
4ecec788d0
@ -669,8 +669,11 @@ self.bulkDeleteExpired = async (dryrun, verbose) => {
|
|||||||
const field = fields[0]
|
const field = fields[0]
|
||||||
const values = result.expired.slice().map(row => row[field])
|
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)
|
||||||
|
if (verbose && result.failed.length) {
|
||||||
|
result.failed = result.failed
|
||||||
|
.map(failed => result.expired.find(file => file[fields[0]] === failed))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
21
lolisafe.js
21
lolisafe.js
@ -382,15 +382,22 @@ safe.use('/api', api)
|
|||||||
|
|
||||||
temporaryUploadsInProgress = true
|
temporaryUploadsInProgress = true
|
||||||
try {
|
try {
|
||||||
const result = await utils.bulkDeleteExpired()
|
const result = await utils.bulkDeleteExpired(false, isDevMode)
|
||||||
|
|
||||||
if (result.expired.length) {
|
if (result.expired.length || result.failed.length) {
|
||||||
let logMessage = `Expired uploads: ${result.expired.length} deleted`
|
if (isDevMode) {
|
||||||
if (result.failed.length) {
|
let logMessage = `Expired uploads (${result.expired.length}): ${result.expired.map(file => file.name).join(', ')}`
|
||||||
logMessage += `, ${result.failed.length} errored`
|
if (result.failed.length) {
|
||||||
|
logMessage += `\nErrored (${result.failed.length}): ${result.failed.map(file => file.name).join(', ')}`
|
||||||
|
}
|
||||||
|
logger.debug(logMessage)
|
||||||
|
} else {
|
||||||
|
let logMessage = `Expired uploads: ${result.expired.length} deleted`
|
||||||
|
if (result.failed.length) {
|
||||||
|
logMessage += `, ${result.failed.length} errored`
|
||||||
|
}
|
||||||
|
logger.log(logMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.log(logMessage)
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Simply print-out errors, then continue
|
// Simply print-out errors, then continue
|
||||||
|
@ -31,9 +31,13 @@ const utils = require('../controllers/utilsController')
|
|||||||
console.log(expired)
|
console.log(expired)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Expired files: ${result.expired.length}`)
|
console.log(`Expired files: ${result.expired.length}`)
|
||||||
|
|
||||||
if (result.failed) {
|
if (result.failed) {
|
||||||
|
console.log('WARNING: Some expired files failed to delete!')
|
||||||
|
for (const failed of result.failed) {
|
||||||
|
console.log(failed)
|
||||||
|
}
|
||||||
console.log(`Failed to delete: ${result.failed.length}`)
|
console.log(`Failed to delete: ${result.failed.length}`)
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
Loading…
Reference in New Issue
Block a user