db/Pad: reversed truthy condition to make core logic evident
Since the original comparison compared for truthy and not for "===", and it's 3 AM now, I blindly negated it, in order to show how fragile it was in the first instance. No functional changes. This is the final commit of this refactoring series.pull/3478/head
parent
69e1bf28aa
commit
1a93ab4eb5
|
@ -505,26 +505,29 @@ Pad.prototype.copy = function copy(destinationID, force, callback) {
|
||||||
{
|
{
|
||||||
if(ERR(err, callback)) return;
|
if(ERR(err, callback)) return;
|
||||||
|
|
||||||
if(exists == true)
|
/*
|
||||||
{
|
* this is the negation of a truthy comparison. Has been left in this
|
||||||
if (!force)
|
* wonky state to keep the old (possibly buggy) behaviour
|
||||||
{
|
*/
|
||||||
console.error("erroring out without force");
|
if (!(exists == true))
|
||||||
callback(new customError("destinationID already exists","apierror"));
|
|
||||||
console.error("erroring out without force - after");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// exists and forcing
|
|
||||||
padManager.getPad(destinationID, function(err, pad) {
|
|
||||||
if (ERR(err, callback)) return;
|
|
||||||
pad.remove(callback);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
callback();
|
callback();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!force)
|
||||||
|
{
|
||||||
|
console.error("erroring out without force");
|
||||||
|
callback(new customError("destinationID already exists","apierror"));
|
||||||
|
console.error("erroring out without force - after");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// exists and forcing
|
||||||
|
padManager.getPad(destinationID, function(err, pad) {
|
||||||
|
if (ERR(err, callback)) return;
|
||||||
|
pad.remove(callback);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// copy the 'pad' entry
|
// copy the 'pad' entry
|
||||||
|
|
Loading…
Reference in New Issue