From 5c864ec47d32593a156855c989b0a39a73f5c315 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Fri, 9 Mar 2018 13:45:24 +0100 Subject: [PATCH] Add checkPad variant to check all pads/revisions --- bin/checkAllPads.js | 138 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 bin/checkAllPads.js diff --git a/bin/checkAllPads.js b/bin/checkAllPads.js new file mode 100644 index 000000000..1657ba794 --- /dev/null +++ b/bin/checkAllPads.js @@ -0,0 +1,138 @@ +/* + This is a debug tool. It checks all revisions of all pads for data corruption +*/ + +if(process.argv.length != 2) +{ + console.error("Use: node bin/checkAllPads.js"); + process.exit(1); +} + +//initalize the variables +var db, settings, padManager; +var npm = require("../src/node_modules/npm"); +var async = require("../src/node_modules/async"); + +var Changeset = require("../src/static/js/Changeset"); + +async.series([ + //load npm + function(callback) { + npm.load({}, callback); + }, + //load modules + function(callback) { + settings = require('../src/node/utils/Settings'); + db = require('../src/node/db/DB'); + + //initalize the database + db.init(callback); + }, + //load pads + function (callback) + { + padManager = require('../src/node/db/PadManager'); + + padManager.listAllPads(function(err, res) + { + var padIds = res.padIDs; + pads = []; + async.forEach(padIds, function(padId, callback) { + padManager.getPad(padId, function(err, pad) { + pads.push(pad); + callback(err); + }) + }, callback); + }); + }, + function (callback) + { + async.forEach(pads, function(pad, callback) + { + //create an array with key kevisions + //key revisions always save the full pad atext + var head = pad.getHeadRevisionNumber(); + var keyRevisions = []; + for(var i=0;i