diff options
author | John McLear <john@mclear.co.uk> | 2014-12-29 14:59:22 +0100 |
---|---|---|
committer | John McLear <john@mclear.co.uk> | 2014-12-29 14:59:22 +0100 |
commit | 302ceb665b2dd123d8c67efe05773646ab7aebbf (patch) | |
tree | 1e98b1f28e874c0c1a9c3b2168dcf909fd31906c /src/node | |
parent | 3fe802077c28c7ddef6e5440806f7f019e804ff2 (diff) | |
download | etherpad-lite-302ceb665b2dd123d8c67efe05773646ab7aebbf.zip |
delay write to fix copypad -- bad practice but due to db.set not allowing callback
Diffstat (limited to 'src/node')
-rw-r--r-- | src/node/db/Pad.js | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/node/db/Pad.js b/src/node/db/Pad.js index 94049ff7..2f5860f8 100644 --- a/src/node/db/Pad.js +++ b/src/node/db/Pad.js @@ -461,7 +461,6 @@ Pad.prototype.copy = function copy(destinationID, force, callback) { // if the pad exists, we should abort, unless forced. function(callback) { - console.log("destinationID", destinationID, force); padManager.doesPadExists(destinationID, function (err, exists) { if(ERR(err, callback)) return; @@ -470,9 +469,9 @@ Pad.prototype.copy = function copy(destinationID, force, callback) { { if (!force) { - console.log("erroring out without force"); + console.error("erroring out without force"); callback(new customError("destinationID already exists","apierror")); - console.log("erroring out without force - after"); + console.error("erroring out without force - after"); return; } else // exists and forcing @@ -521,12 +520,9 @@ Pad.prototype.copy = function copy(destinationID, force, callback) { function(callback) { var revHead = _this.head; - //console.log(revHead); for(var i=0;i<=revHead;i++) { db.get("pad:"+sourceID+":revs:"+i, function (err, rev) { - //console.log("HERE"); - if (ERR(err, callback)) return; db.set("pad:"+destinationID+":revs:"+i, rev); }); @@ -538,10 +534,8 @@ Pad.prototype.copy = function copy(destinationID, force, callback) { function(callback) { var authorIDs = _this.getAllAuthors(); - authorIDs.forEach(function (authorID) { - console.log("authors"); authorManager.addPad(authorID, destinationID); }); @@ -555,7 +549,9 @@ Pad.prototype.copy = function copy(destinationID, force, callback) { if(destGroupID) db.setSub("group:" + destGroupID, ["pads", destinationID], 1); // Initialize the new pad (will update the listAllPads cache) - padManager.getPad(destinationID, null, callback) + setTimeout(function(){ + padManager.getPad(destinationID, null, callback) // this runs too early. + },10); } // series ], function(err) |