Add more detail for the modes

GitOrigin-RevId: 44b63b76b1edb8bfb78049c9c8560934e340ef96
This commit is contained in:
Andrew Rumble
2025-06-06 12:37:18 +01:00
committed by Copybot
parent 6ed488cc65
commit 745043ca92

View File

@@ -14,12 +14,24 @@ import { client } from '../lib/mongodb.js'
import archiver from 'archiver'
import Events from 'node:events'
import { Chunk } from 'overleaf-editor-core'
import _ from 'lodash'
// Silence warning.
Events.setMaxListeners(20)
const SUPPORTED_MODES = ['raw', 'latest']
// Pads the mode name to a fixed length for better alignment in output.
const padModeName = _.partialRight(
_.padEnd,
Math.max(...SUPPORTED_MODES.map(mode => mode.length))
)
const SUPPORTED_MODES_HELP = {
raw: 'Retrieve all chunk and blob files from the project backup.',
latest: 'Retrieves the last backed up state of the project.',
}
// outputFile needs to be available in the shutdown function (which may be called before it's declared)
// eslint-disable-next-line prefer-const
let outputFile
@@ -42,10 +54,15 @@ function usage() {
console.log(
'Usage: node recover_zip_from_backup.mjs --historyId=<historyId> --output=<output> [--mode=<mode>] [--verbose] [--useBackupGlobalBlobs]'
)
console.log('Supported modes: ' + SUPPORTED_MODES.join(', '))
console.log(
'--useBackupGlobalBlobs can be used if the global blobs have not been restored from the backup yet.'
)
console.log('Supported modes: ' + SUPPORTED_MODES.join(', '))
SUPPORTED_MODES.forEach(mode => {
console.log(
` --mode=${padModeName(mode)} - ${SUPPORTED_MODES_HELP[mode] || ''}`
)
})
}
/**