From 6b208753552001cf0664db2f4c4e45d0ed094e8a Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Mon, 5 Dec 2011 18:24:59 +0100 Subject: [PATCH] add a tool to check for data corruption on pads --- bin/checkPad.js | 133 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 bin/checkPad.js 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