mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
checkPadDeltas: version by JohnMcLear
From https://github.com/ether/etherpad-lite/pull/3717#issuecomment-602179127 > Afaik I used async / await that's pretty much all, I think I had to do some > polish because something was broken, remember stuff like pad.getPadAuthors was > b0rked in 1.7 or so
This commit is contained in:
parent
90f9b8a3bd
commit
14ae2ee950
1 changed files with 67 additions and 101 deletions
|
@ -1,77 +1,44 @@
|
||||||
/*
|
/*
|
||||||
This is a debug tool. It checks all revisions for data corruption
|
* This is a debug tool. It checks all revisions for data corruption
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(process.argv.length != 3)
|
if (process.argv.length != 3) {
|
||||||
{
|
console.error("Use: node bin/checkPadDeltas.js $PADID");
|
||||||
console.error("Use: node bin/checkPad.js $PADID");
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
//get the padID
|
|
||||||
var padId = process.argv[2];
|
|
||||||
|
|
||||||
//initalize the variables
|
// get the padID
|
||||||
var db, settings, padManager;
|
const padId = process.argv[2];
|
||||||
var npm = require("ep_etherpad-lite/node_modules/npm");
|
|
||||||
var async = require("ep_etherpad-lite/node_modules/async");
|
|
||||||
|
|
||||||
var Changeset = require("ep_etherpad-lite/static/js/Changeset");
|
// load and initialize NPM;
|
||||||
|
|
||||||
// external dependencies
|
|
||||||
var expect = require('expect.js')
|
var expect = require('expect.js')
|
||||||
var diff = require('diff')
|
var diff = require('diff')
|
||||||
|
var async = require('async')
|
||||||
|
|
||||||
async.series([
|
let npm = require('../src/node_modules/npm');
|
||||||
//load npm
|
var async = require("ep_etherpad-lite/node_modules/async");
|
||||||
function(callback) {
|
var Changeset = require("ep_etherpad-lite/static/js/Changeset");
|
||||||
npm.load({}, function(er) {
|
|
||||||
callback(er);
|
|
||||||
})
|
|
||||||
},
|
|
||||||
//load modules
|
|
||||||
function(callback) {
|
|
||||||
settings = require('ep_etherpad-lite/node/utils/Settings');
|
|
||||||
db = require('ep_etherpad-lite/node/db/DB');
|
|
||||||
|
|
||||||
//intallize the database
|
npm.load({}, async function() {
|
||||||
db.init(callback);
|
|
||||||
},
|
|
||||||
//get the pad
|
|
||||||
function (callback)
|
|
||||||
{
|
|
||||||
padManager = require('ep_etherpad-lite/node/db/PadManager');
|
|
||||||
|
|
||||||
padManager.doesPadExists(padId, function(err, exists)
|
try {
|
||||||
{
|
// initialize database
|
||||||
if(!exists)
|
let settings = require('../src/node/utils/Settings');
|
||||||
{
|
let db = require('../src/node/db/DB');
|
||||||
|
await db.init();
|
||||||
|
|
||||||
|
// load modules
|
||||||
|
let Changeset = require('ep_etherpad-lite/static/js/Changeset');
|
||||||
|
let padManager = require('../src/node/db/PadManager');
|
||||||
|
|
||||||
|
let exists = await padManager.doesPadExists(padId);
|
||||||
|
if (!exists) {
|
||||||
console.error("Pad does not exist");
|
console.error("Pad does not exist");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
padManager.getPad(padId, function(err, _pad)
|
// get the pad
|
||||||
{
|
let pad = await padManager.getPad(padId);
|
||||||
pad = _pad;
|
|
||||||
callback(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
function (callback)
|
|
||||||
{
|
|
||||||
//check if the pad has a pool
|
|
||||||
if(pad.pool === undefined )
|
|
||||||
{
|
|
||||||
console.error("Attribute pool is missing");
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//check if the pad has atext
|
|
||||||
if(pad.atext === undefined )
|
|
||||||
{
|
|
||||||
console.error("AText is missing");
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//create an array with key revisions
|
//create an array with key revisions
|
||||||
//key revisions always save the full pad atext
|
//key revisions always save the full pad atext
|
||||||
|
@ -142,13 +109,12 @@ async.series([
|
||||||
}
|
}
|
||||||
callback(er)
|
callback(er)
|
||||||
});
|
});
|
||||||
}
|
|
||||||
], function (err)
|
|
||||||
{
|
|
||||||
if(err) throw err;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
console.log("finished");
|
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
console.trace(e);
|
||||||
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue