lint: Convert CR+LF line endings to LF

This commit is contained in:
Richard Hansen 2020-11-20 23:57:42 -05:00 committed by John McLear
parent a78d6605b7
commit cc988bd67b
6 changed files with 243 additions and 243 deletions

View file

@ -1,120 +1,120 @@
/* /*
* 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/checkPadDeltas.js $PADID");
process.exit(1); process.exit(1);
} }
// get the padID // get the padID
const padId = process.argv[2]; const padId = process.argv[2];
// load and initialize NPM; // load and initialize NPM;
var expect = require('expect.js') var expect = require('expect.js')
var diff = require('diff') var diff = require('diff')
var async = require('async') var async = require('async')
let npm = require('../src/node_modules/npm'); let npm = require('../src/node_modules/npm');
var async = require("ep_etherpad-lite/node_modules/async"); var async = require("ep_etherpad-lite/node_modules/async");
var Changeset = require("ep_etherpad-lite/static/js/Changeset"); var Changeset = require("ep_etherpad-lite/static/js/Changeset");
npm.load({}, async function() { npm.load({}, async function() {
try { try {
// initialize database // initialize database
let settings = require('../src/node/utils/Settings'); let settings = require('../src/node/utils/Settings');
let db = require('../src/node/db/DB'); let db = require('../src/node/db/DB');
await db.init(); await db.init();
// load modules // load modules
let Changeset = require('ep_etherpad-lite/static/js/Changeset'); let Changeset = require('ep_etherpad-lite/static/js/Changeset');
let padManager = require('../src/node/db/PadManager'); let padManager = require('../src/node/db/PadManager');
let exists = await padManager.doesPadExists(padId); let exists = await padManager.doesPadExists(padId);
if (!exists) { if (!exists) {
console.error("Pad does not exist"); console.error("Pad does not exist");
process.exit(1); process.exit(1);
} }
// get the pad // get the pad
let pad = await padManager.getPad(padId); let pad = await padManager.getPad(padId);
//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
var head = pad.getHeadRevisionNumber(); var head = pad.getHeadRevisionNumber();
var keyRevisions = []; var keyRevisions = [];
for(var i=0;i<head;i+=100) for(var i=0;i<head;i+=100)
{ {
keyRevisions.push(i); keyRevisions.push(i);
} }
//create an array with all revisions //create an array with all revisions
var revisions = []; var revisions = [];
for(var i=0;i<=head;i++) for(var i=0;i<=head;i++)
{ {
revisions.push(i); revisions.push(i);
} }
var atext = Changeset.makeAText("\n") var atext = Changeset.makeAText("\n")
//run trough all revisions //run trough all revisions
async.forEachSeries(revisions, function(revNum, callback) async.forEachSeries(revisions, function(revNum, callback)
{ {
//console.log('Fetching', revNum) //console.log('Fetching', revNum)
db.db.get("pad:"+padId+":revs:" + revNum, function(err, revision) db.db.get("pad:"+padId+":revs:" + revNum, function(err, revision)
{ {
if(err) return callback(err); if(err) return callback(err);
//check if there is a atext in the keyRevisions //check if there is a atext in the keyRevisions
if(~keyRevisions.indexOf(revNum) && (revision === undefined || revision.meta === undefined || revision.meta.atext === undefined)) { if(~keyRevisions.indexOf(revNum) && (revision === undefined || revision.meta === undefined || revision.meta.atext === undefined)) {
console.error("No atext in key revision " + revNum); console.error("No atext in key revision " + revNum);
callback(); callback();
return; return;
} }
try { try {
//console.log("check revision ", revNum); //console.log("check revision ", revNum);
var cs = revision.changeset; var cs = revision.changeset;
atext = Changeset.applyToAText(cs, atext, pad.pool); atext = Changeset.applyToAText(cs, atext, pad.pool);
} }
catch(e) { catch(e) {
console.error("Bad changeset at revision " + revNum + " - " + e.message); console.error("Bad changeset at revision " + revNum + " - " + e.message);
callback(); callback();
return; return;
} }
if(~keyRevisions.indexOf(revNum)) { if(~keyRevisions.indexOf(revNum)) {
try { try {
expect(revision.meta.atext.text).to.eql(atext.text) expect(revision.meta.atext.text).to.eql(atext.text)
expect(revision.meta.atext.attribs).to.eql(atext.attribs) expect(revision.meta.atext.attribs).to.eql(atext.attribs)
}catch(e) { }catch(e) {
console.error("Atext in key revision "+revNum+" doesn't match computed one.") console.error("Atext in key revision "+revNum+" doesn't match computed one.")
console.log(diff.diffChars(atext.text, revision.meta.atext.text).map(function(op) {if(!op.added && !op.removed) op.value = op.value.length; return op})) console.log(diff.diffChars(atext.text, revision.meta.atext.text).map(function(op) {if(!op.added && !op.removed) op.value = op.value.length; return op}))
//console.error(e) //console.error(e)
//console.log('KeyRev. :', revision.meta.atext) //console.log('KeyRev. :', revision.meta.atext)
//console.log('Computed:', atext) //console.log('Computed:', atext)
callback() callback()
return return
} }
} }
setImmediate(callback) setImmediate(callback)
}); });
}, function(er) { }, function(er) {
if(pad.atext.text == atext.text) console.log('ok') if(pad.atext.text == atext.text) console.log('ok')
else { else {
console.error('Pad AText doesn\'t match computed one! (Computed ',atext.text.length, ', db', pad.atext.text.length,')') console.error('Pad AText doesn\'t match computed one! (Computed ',atext.text.length, ', db', pad.atext.text.length,')')
console.log(diff.diffChars(atext.text, pad.atext.text).map(function(op) {if(!op.added && !op.removed) op.value = op.value.length; return op})) console.log(diff.diffChars(atext.text, pad.atext.text).map(function(op) {if(!op.added && !op.removed) op.value = op.value.length; return op}))
} }
callback(er) callback(er)
}); });
process.exit(0); process.exit(0);
} catch (e) { } catch (e) {
console.trace(e); console.trace(e);
process.exit(1); process.exit(1);
} }
}); });

View file

@ -1,13 +1,13 @@
Copyright [yyyy] [name of copyright owner] Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
You may obtain a copy of the License at You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.

View file

@ -1,5 +1,5 @@
.ep_initialized .ep_initialized
.DS_Store .DS_Store
node_modules/ node_modules/
node_modules node_modules
npm-debug.log npm-debug.log

View file

@ -1,44 +1,44 @@
const semver = require('semver'); const semver = require('semver');
const settings = require('./Settings'); const settings = require('./Settings');
const request = require('request'); const request = require('request');
let infos; let infos;
function loadEtherpadInformations() { function loadEtherpadInformations() {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
request('https://static.etherpad.org/info.json', function (er, response, body) { request('https://static.etherpad.org/info.json', function (er, response, body) {
if (er) return reject(er); if (er) return reject(er);
try { try {
infos = JSON.parse(body); infos = JSON.parse(body);
return resolve(infos); return resolve(infos);
} catch (err) { } catch (err) {
return reject(err); return reject(err);
} }
}); });
}) })
} }
exports.getLatestVersion = function() { exports.getLatestVersion = function() {
exports.needsUpdate(); exports.needsUpdate();
return infos.latestVersion; return infos.latestVersion;
} }
exports.needsUpdate = function(cb) { exports.needsUpdate = function(cb) {
loadEtherpadInformations().then(function(info) { loadEtherpadInformations().then(function(info) {
if (semver.gt(info.latestVersion, settings.getEpVersion())) { if (semver.gt(info.latestVersion, settings.getEpVersion())) {
if (cb) return cb(true); if (cb) return cb(true);
} }
}).catch(function (err) { }).catch(function (err) {
console.error('Can not perform Etherpad update check: ' + err) console.error('Can not perform Etherpad update check: ' + err)
if (cb) return cb(false); if (cb) return cb(false);
}) })
} }
exports.check = function() { exports.check = function() {
exports.needsUpdate(function (needsUpdate) { exports.needsUpdate(function (needsUpdate) {
if (needsUpdate) { if (needsUpdate) {
console.warn('Update available: Download the actual version ' + infos.latestVersion) console.warn('Update available: Download the actual version ' + infos.latestVersion)
} }
}) })
} }

File diff suppressed because one or more lines are too long

View file

@ -1,51 +1,51 @@
describe('author of pad edition', function() { describe('author of pad edition', function() {
// author 1 creates a new pad with some content (regular lines and lists) // author 1 creates a new pad with some content (regular lines and lists)
before(function(done) { before(function(done) {
var padId = helper.newPad(function() { var padId = helper.newPad(function() {
// make sure pad has at least 3 lines // make sure pad has at least 3 lines
var $firstLine = helper.padInner$('div').first(); var $firstLine = helper.padInner$('div').first();
$firstLine.html("Hello World"); $firstLine.html("Hello World");
// wait for lines to be processed by Etherpad // wait for lines to be processed by Etherpad
helper.waitFor(function() { helper.waitFor(function() {
return $firstLine.text() === 'Hello World'; return $firstLine.text() === 'Hello World';
}).done(function() { }).done(function() {
// Reload pad, to make changes as a second user. Need a timeout here to make sure // Reload pad, to make changes as a second user. Need a timeout here to make sure
// all changes were saved before reloading // all changes were saved before reloading
setTimeout(function() { setTimeout(function() {
// Expire cookie, so author is changed after reloading the pad. // Expire cookie, so author is changed after reloading the pad.
// See https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#Example_4_Reset_the_previous_cookie // See https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#Example_4_Reset_the_previous_cookie
helper.padChrome$.document.cookie = 'token=foo;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/'; helper.padChrome$.document.cookie = 'token=foo;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
helper.newPad(done, padId); helper.newPad(done, padId);
}, 1000); }, 1000);
}); });
}); });
this.timeout(60000); this.timeout(60000);
}); });
// author 2 makes some changes on the pad // author 2 makes some changes on the pad
it('Clears Authorship by second user', function(done) { it('Clears Authorship by second user', function(done) {
clearAuthorship(done); clearAuthorship(done);
}); });
var clearAuthorship = function(done){ var clearAuthorship = function(done){
var inner$ = helper.padInner$; var inner$ = helper.padInner$;
var chrome$ = helper.padChrome$; var chrome$ = helper.padChrome$;
// override the confirm dialogue functioon // override the confirm dialogue functioon
helper.padChrome$.window.confirm = function(){ helper.padChrome$.window.confirm = function(){
return true; return true;
} }
//get the clear authorship colors button and click it //get the clear authorship colors button and click it
var $clearauthorshipcolorsButton = chrome$(".buttonicon-clearauthorship"); var $clearauthorshipcolorsButton = chrome$(".buttonicon-clearauthorship");
$clearauthorshipcolorsButton.click(); $clearauthorshipcolorsButton.click();
// does the first divs span include an author class? // does the first divs span include an author class?
var hasAuthorClass = inner$("div span").first().attr("class").indexOf("author") !== -1; var hasAuthorClass = inner$("div span").first().attr("class").indexOf("author") !== -1;
expect(hasAuthorClass).to.be(false) expect(hasAuthorClass).to.be(false)
done(); done();
} }
}); });