summaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
authorJohn McLear <john@mclear.co.uk>2014-12-29 14:59:22 +0100
committerJohn McLear <john@mclear.co.uk>2014-12-29 14:59:22 +0100
commit302ceb665b2dd123d8c67efe05773646ab7aebbf (patch)
tree1e98b1f28e874c0c1a9c3b2168dcf909fd31906c /src/node
parent3fe802077c28c7ddef6e5440806f7f019e804ff2 (diff)
downloadetherpad-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.js14
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)