pad.libre-service.eu-etherpad/bin/checkAllPads.ts

30 lines
984 B
TypeScript
Raw Permalink Normal View History

'use strict';
/*
* This is a debug tool. It checks all revisions for data corruption
*/
2024-03-15 20:59:28 +01:00
import process from "node:process";
// As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an
// unhandled rejection into an uncaught exception, which does cause Node.js to exit.
process.on('unhandledRejection', (err) => { throw err; });
if (process.argv.length !== 2) throw new Error('Use: node bin/checkAllPads.js');
2021-01-09 08:44:59 +01:00
(async () => {
2024-03-13 20:31:29 +01:00
const db = require('ep_etherpad-lite/node/db/DB');
await db.init();
2024-03-13 20:31:29 +01:00
const padManager = require('ep_etherpad-lite/node/db/PadManager');
await Promise.all((await padManager.listAllPads()).padIDs.map(async (padId: string) => {
const pad = await padManager.getPad(padId);
2021-11-27 09:37:34 +01:00
try {
await pad.check();
2024-03-13 20:31:29 +01:00
} catch (err:any) {
2021-11-27 09:37:34 +01:00
console.error(`Error in pad ${padId}: ${err.stack || err}`);
return;
}
2021-11-27 09:37:34 +01:00
console.log(`Pad ${padId}: OK`);
}));
console.log('Finished.');
2024-08-08 21:23:10 +02:00
process.exit(0)
2021-01-09 08:44:59 +01:00
})();