mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
allow only for pads less than 10 to be overwritten
This commit is contained in:
parent
ab5e7381a2
commit
a6400b3f61
2 changed files with 18 additions and 7 deletions
|
@ -121,13 +121,25 @@ exports.doImport = function(req, res, padId)
|
||||||
function(callback) {
|
function(callback) {
|
||||||
var fileEnding = path.extname(srcFile).toLowerCase()
|
var fileEnding = path.extname(srcFile).toLowerCase()
|
||||||
var fileIsEtherpad = (fileEnding === ".etherpad");
|
var fileIsEtherpad = (fileEnding === ".etherpad");
|
||||||
|
|
||||||
if(fileIsEtherpad){
|
if(fileIsEtherpad){
|
||||||
|
// we do this here so we can see if the pad has quit ea few edits
|
||||||
|
padManager.getPad(padId, function(err, _pad){
|
||||||
|
console.error(_pad);
|
||||||
|
var headCount = _pad.head;
|
||||||
|
console.error(headCount);
|
||||||
|
if(headCount >= 10){
|
||||||
|
apiLogger.warn("Direct database Import attempt of a pad that already has content, we wont be doing this")
|
||||||
|
return callback("padHasData");
|
||||||
|
}else{
|
||||||
fs.readFile(srcFile, "utf8", function(err, _text){
|
fs.readFile(srcFile, "utf8", function(err, _text){
|
||||||
directDatabaseAccess = true;
|
directDatabaseAccess = true;
|
||||||
importEtherpad.setPadRaw(padId, _text, function(err){
|
importEtherpad.setPadRaw(padId, _text, function(err){
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}else{
|
}else{
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
@ -264,7 +276,7 @@ exports.doImport = function(req, res, padId)
|
||||||
var status = "ok";
|
var status = "ok";
|
||||||
|
|
||||||
//check for known errors and replace the status
|
//check for known errors and replace the status
|
||||||
if(err == "uploadFailed" || err == "convertFailed")
|
if(err == "uploadFailed" || err == "convertFailed" || err == "padHasData")
|
||||||
{
|
{
|
||||||
status = err;
|
status = err;
|
||||||
err = null;
|
err = null;
|
||||||
|
|
|
@ -23,7 +23,6 @@ exports.setPadRaw = function(padId, records, callback){
|
||||||
|
|
||||||
async.eachSeries(Object.keys(records), function(key, cb){
|
async.eachSeries(Object.keys(records), function(key, cb){
|
||||||
var value = records[key]
|
var value = records[key]
|
||||||
|
|
||||||
// rewrite padId
|
// rewrite padId
|
||||||
var oldPadId = key.split(":");
|
var oldPadId = key.split(":");
|
||||||
oldPadId[1] = padId;
|
oldPadId[1] = padId;
|
||||||
|
|
Loading…
Reference in a new issue