verify_backup_blob.mjs 546 B

123456789101112131415161718192021
  1. import logger from '@overleaf/logger'
  2. import commandLineArgs from 'command-line-args'
  3. import { verifyBlobs } from '../lib/backupVerifier.mjs'
  4. const { historyId, hashes } = commandLineArgs([
  5. { name: 'historyId', type: String },
  6. { name: 'hashes', type: String, multiple: true, defaultOption: true },
  7. ])
  8. if (hashes.length === 0) {
  9. throw new Error('missing --hashes flag')
  10. }
  11. try {
  12. await verifyBlobs(historyId, hashes)
  13. console.log('OK')
  14. process.exit(0)
  15. } catch (err) {
  16. logger.err({ err }, 'failed to verify blob')
  17. process.exit(1)
  18. }