mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-14 16:36:21 +00:00
02e2e402c3
As the title says, this commit is a massive overhaul. I've rewritten/restrucuted almost everything in the controller scripts. Because of that, there's a considerable possibility that I've broken something somewhere. Notable changes: Added temporary uploads. Removed file name length changer from dashboard, in favor of an equivalent in homepage config tab. This allows non-registered users to also set file name length. A bunch of other undocmented stuff. I don't know, I'm too tired to remember them all.
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
const { stripIndents } = require('./_utils')
|
|
const utils = require('./../controllers/utilsController')
|
|
|
|
const self = {
|
|
mode: null
|
|
}
|
|
|
|
;(async () => {
|
|
const location = process.argv[1].replace(process.cwd() + '/', '')
|
|
const args = process.argv.slice(2)
|
|
|
|
self.mode = parseInt(args[0]) || 0
|
|
|
|
if (args.includes('--help') || args.includes('-h'))
|
|
return console.log(stripIndents(`
|
|
Bulk delete expired files.
|
|
|
|
Usage:
|
|
node ${location} [mode=0|1|2]
|
|
|
|
mode:
|
|
0 = Only list names of the expired files.
|
|
1 = Delete expired files (output file names).
|
|
2 = Delete expired files (no output).
|
|
`))
|
|
|
|
const dryrun = self.mode === 0
|
|
const quiet = self.mode === 2
|
|
|
|
const result = await utils.bulkDeleteExpired(dryrun)
|
|
|
|
if (quiet) return
|
|
|
|
if (result.expired.length)
|
|
for (const expired of result.expired)
|
|
console.log(expired)
|
|
|
|
console.log(`Expired files: ${result.expired.length}`)
|
|
if (result.failed)
|
|
console.log(`Failed to delete: ${result.failed.length}`)
|
|
})()
|
|
.then(() => process.exit(0))
|
|
.catch(error => {
|
|
console.error(error)
|
|
process.exit(1)
|
|
})
|