summaryrefslogtreecommitdiff
path: root/src/node/handler/ImportHandler.js
diff options
context:
space:
mode:
authorJohn McLear <john@mclear.co.uk>2014-12-29 22:02:24 +0100
committerJohn McLear <john@mclear.co.uk>2014-12-29 22:02:24 +0100
commita6400b3f619cc62602afa8fc9c6ff1686c8aa089 (patch)
treee433357d0cdb9b268e4d14d1f4248ef76c715727 /src/node/handler/ImportHandler.js
parentab5e7381a29ae442ede7dde760f7d69a9228fe80 (diff)
downloadetherpad-lite-a6400b3f619cc62602afa8fc9c6ff1686c8aa089.zip
allow only for pads less than 10 to be overwritten
Diffstat (limited to 'src/node/handler/ImportHandler.js')
-rw-r--r--src/node/handler/ImportHandler.js24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/node/handler/ImportHandler.js b/src/node/handler/ImportHandler.js
index 813a8d19..af4c01f1 100644
--- a/src/node/handler/ImportHandler.js
+++ b/src/node/handler/ImportHandler.js
@@ -121,12 +121,24 @@ exports.doImport = function(req, res, padId)
function(callback) {
var fileEnding = path.extname(srcFile).toLowerCase()
var fileIsEtherpad = (fileEnding === ".etherpad");
+
if(fileIsEtherpad){
- fs.readFile(srcFile, "utf8", function(err, _text){
- directDatabaseAccess = true;
- importEtherpad.setPadRaw(padId, _text, function(err){
- callback();
- });
+ // 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){
+ directDatabaseAccess = true;
+ importEtherpad.setPadRaw(padId, _text, function(err){
+ callback();
+ });
+ });
+ }
});
}else{
callback();
@@ -264,7 +276,7 @@ exports.doImport = function(req, res, padId)
var status = "ok";
//check for known errors and replace the status
- if(err == "uploadFailed" || err == "convertFailed")
+ if(err == "uploadFailed" || err == "convertFailed" || err == "padHasData")
{
status = err;
err = null;