2021-01-18 09:53:15 +01:00
|
|
|
'use strict';
|
2018-03-09 13:45:24 +01:00
|
|
|
/*
|
2019-02-08 23:20:57 +01:00
|
|
|
* This is a debug tool. It checks all revisions for data corruption
|
|
|
|
*/
|
2018-03-09 13:45:24 +01:00
|
|
|
|
2021-01-18 09:53:15 +01:00
|
|
|
// 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; });
|
|
|
|
|
2021-02-05 00:43:27 +01:00
|
|
|
if (process.argv.length !== 2) throw new Error('Use: node src/bin/checkAllPads.js');
|
2018-03-09 13:45:24 +01:00
|
|
|
|
2021-01-09 08:44:59 +01:00
|
|
|
(async () => {
|
2021-02-03 13:08:43 +01:00
|
|
|
const db = require('../node/db/DB');
|
2021-01-17 09:16:01 +01:00
|
|
|
await db.init();
|
2021-02-03 13:08:43 +01:00
|
|
|
const padManager = require('../node/db/PadManager');
|
2021-11-27 09:37:34 +01:00
|
|
|
await Promise.all((await padManager.listAllPads()).padIDs.map(async (padId) => {
|
2021-01-17 09:16:01 +01:00
|
|
|
const pad = await padManager.getPad(padId);
|
2021-11-27 09:37:34 +01:00
|
|
|
try {
|
|
|
|
await pad.check();
|
|
|
|
} catch (err) {
|
|
|
|
console.error(`Error in pad ${padId}: ${err.stack || err}`);
|
|
|
|
return;
|
2019-01-27 00:52:02 +01:00
|
|
|
}
|
2021-11-27 09:37:34 +01:00
|
|
|
console.log(`Pad ${padId}: OK`);
|
|
|
|
}));
|
|
|
|
console.log('Finished.');
|
2021-01-09 08:44:59 +01:00
|
|
|
})();
|