mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
delay write to fix copypad -- bad practice but due to db.set not allowing callback
This commit is contained in:
parent
3fe802077c
commit
302ceb665b
1 changed files with 5 additions and 9 deletions
|
@ -461,7 +461,6 @@ Pad.prototype.copy = function copy(destinationID, force, callback) {
|
||||||
// if the pad exists, we should abort, unless forced.
|
// if the pad exists, we should abort, unless forced.
|
||||||
function(callback)
|
function(callback)
|
||||||
{
|
{
|
||||||
console.log("destinationID", destinationID, force);
|
|
||||||
padManager.doesPadExists(destinationID, function (err, exists)
|
padManager.doesPadExists(destinationID, function (err, exists)
|
||||||
{
|
{
|
||||||
if(ERR(err, callback)) return;
|
if(ERR(err, callback)) return;
|
||||||
|
@ -470,9 +469,9 @@ Pad.prototype.copy = function copy(destinationID, force, callback) {
|
||||||
{
|
{
|
||||||
if (!force)
|
if (!force)
|
||||||
{
|
{
|
||||||
console.log("erroring out without force");
|
console.error("erroring out without force");
|
||||||
callback(new customError("destinationID already exists","apierror"));
|
callback(new customError("destinationID already exists","apierror"));
|
||||||
console.log("erroring out without force - after");
|
console.error("erroring out without force - after");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else // exists and forcing
|
else // exists and forcing
|
||||||
|
@ -521,12 +520,9 @@ Pad.prototype.copy = function copy(destinationID, force, callback) {
|
||||||
function(callback)
|
function(callback)
|
||||||
{
|
{
|
||||||
var revHead = _this.head;
|
var revHead = _this.head;
|
||||||
//console.log(revHead);
|
|
||||||
for(var i=0;i<=revHead;i++)
|
for(var i=0;i<=revHead;i++)
|
||||||
{
|
{
|
||||||
db.get("pad:"+sourceID+":revs:"+i, function (err, rev) {
|
db.get("pad:"+sourceID+":revs:"+i, function (err, rev) {
|
||||||
//console.log("HERE");
|
|
||||||
|
|
||||||
if (ERR(err, callback)) return;
|
if (ERR(err, callback)) return;
|
||||||
db.set("pad:"+destinationID+":revs:"+i, rev);
|
db.set("pad:"+destinationID+":revs:"+i, rev);
|
||||||
});
|
});
|
||||||
|
@ -538,10 +534,8 @@ Pad.prototype.copy = function copy(destinationID, force, callback) {
|
||||||
function(callback)
|
function(callback)
|
||||||
{
|
{
|
||||||
var authorIDs = _this.getAllAuthors();
|
var authorIDs = _this.getAllAuthors();
|
||||||
|
|
||||||
authorIDs.forEach(function (authorID)
|
authorIDs.forEach(function (authorID)
|
||||||
{
|
{
|
||||||
console.log("authors");
|
|
||||||
authorManager.addPad(authorID, destinationID);
|
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);
|
if(destGroupID) db.setSub("group:" + destGroupID, ["pads", destinationID], 1);
|
||||||
|
|
||||||
// Initialize the new pad (will update the listAllPads cache)
|
// 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
|
// series
|
||||||
], function(err)
|
], function(err)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue