diff --git a/bin/checkPad.js b/bin/checkPad.js new file mode 100644 index 00000000..9e054441 --- /dev/null +++ b/bin/checkPad.js @@ -0,0 +1,133 @@ +/* + This is a debug tool. It checks all revisions for data corruption +*/ + +if(process.argv.length != 3) +{ + console.error("Use: node checkPad.js $PADID"); + process.exit(1); +} +//get the padID +var padId = process.argv[2]; + +//initalize the database +var log4js = require("log4js"); +log4js.setGlobalLogLevel("INFO"); +var async = require("async"); +var db = require('../node/db/DB'); +var Changeset = require('../node/utils/Changeset'); +var padManager; + +async.series([ + //intallize the database + function (callback) + { + db.init(callback); + }, + //get the pad + function (callback) + { + padManager = require('../node/db/PadManager'); + + padManager.doesPadExists(padId, function(err, exists) + { + if(!exists) + { + console.error("Pad does not exist"); + process.exit(1); + } + + padManager.getPad(padId, function(err, _pad) + { + pad = _pad; + callback(err); + }); + }); + }, + function (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