overleaf/services/history-v1/storage/tasks/delete_old_chunks.js
Alf Eaton ee85d948e2 Avoid duplicating a math-closing dollar sign (#11227)
GitOrigin-RevId: ef2ef77e26df59d1af3df6dc664e284d3c70102d
2023-01-16 08:41:42 +00:00

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)
})
}