mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-25 06:21:04 +00:00
ee85d948e2
GitOrigin-RevId: ef2ef77e26df59d1af3df6dc664e284d3c70102d
36 lines
943 B
JavaScript
36 lines
943 B
JavaScript
#!/usr/bin/env node
|
|
|
|
'use strict'
|
|
|
|
const commandLineArgs = require('command-line-args')
|
|
const { chunkStore } = require('../')
|
|
|
|
async function deleteOldChunks(options) {
|
|
const deletedChunksTotal = await chunkStore.deleteOldChunks(options)
|
|
console.log(`Deleted ${deletedChunksTotal} old chunks`)
|
|
}
|
|
|
|
exports.deleteOldChunks = deleteOldChunks
|
|
|
|
if (require.main === module) {
|
|
const options = commandLineArgs([
|
|
{ name: 'batch-size', type: Number },
|
|
{ name: 'max-batches', type: Number },
|
|
{ name: 'min-age', type: Number },
|
|
{ name: 'timeout', type: Number },
|
|
{ name: 'verbose', type: Boolean, alias: 'v', defaultValue: false },
|
|
])
|
|
deleteOldChunks({
|
|
batchSize: options['batch-size'],
|
|
maxBatches: options['max-batches'],
|
|
timeout: options.timeout,
|
|
minAgeSecs: options['min-age'],
|
|
})
|
|
.then(() => {
|
|
process.exit()
|
|
})
|
|
.catch(err => {
|
|
console.error(err)
|
|
process.exit(1)
|
|
})
|
|
}
|