diff --git a/controllers/utilsController.js b/controllers/utilsController.js index eb4a00a..bddba4f 100644 --- a/controllers/utilsController.js +++ b/controllers/utilsController.js @@ -669,8 +669,11 @@ self.bulkDeleteExpired = async (dryrun, verbose) => { const field = fields[0] const values = result.expired.slice().map(row => row[field]) 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 } diff --git a/lolisafe.js b/lolisafe.js index e52ff64..0a0dece 100644 --- a/lolisafe.js +++ b/lolisafe.js @@ -382,15 +382,22 @@ safe.use('/api', api) temporaryUploadsInProgress = true try { - const result = await utils.bulkDeleteExpired() + const result = await utils.bulkDeleteExpired(false, isDevMode) - if (result.expired.length) { - let logMessage = `Expired uploads: ${result.expired.length} deleted` - if (result.failed.length) { - logMessage += `, ${result.failed.length} errored` + if (result.expired.length || result.failed.length) { + if (isDevMode) { + let logMessage = `Expired uploads (${result.expired.length}): ${result.expired.map(file => file.name).join(', ')}` + 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) { // Simply print-out errors, then continue diff --git a/scripts/delete-expired.js b/scripts/delete-expired.js index 31eaf54..4791899 100644 --- a/scripts/delete-expired.js +++ b/scripts/delete-expired.js @@ -31,9 +31,13 @@ const utils = require('../controllers/utilsController') console.log(expired) } } - console.log(`Expired files: ${result.expired.length}`) + 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}`) } })()