From 745043ca9269c87750ba29fae37d576afe7b22bb Mon Sep 17 00:00:00 2001 From: Andrew Rumble Date: Fri, 6 Jun 2025 12:37:18 +0100 Subject: [PATCH] Add more detail for the modes GitOrigin-RevId: 44b63b76b1edb8bfb78049c9c8560934e340ef96 --- .../scripts/recover_zip_from_backup.mjs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/services/history-v1/storage/scripts/recover_zip_from_backup.mjs b/services/history-v1/storage/scripts/recover_zip_from_backup.mjs index a16c450092..4cf7051fcd 100644 --- a/services/history-v1/storage/scripts/recover_zip_from_backup.mjs +++ b/services/history-v1/storage/scripts/recover_zip_from_backup.mjs @@ -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= --output= [--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] || ''}` + ) + }) } /**