From d931a700b442eab0b9042e5acf7e7eacee71a493 Mon Sep 17 00:00:00 2001 From: muxator Date: Wed, 29 Aug 2018 02:49:40 +0200 Subject: [PATCH] db/Pad: reversed condition to make error handling evident. No functional changes Here it was legal to replace a lax comparison with a strict one, since we are using indexOf(), whose return value is known. --- src/node/db/Pad.js | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/node/db/Pad.js b/src/node/db/Pad.js index 6386e8b58..f5d65e6ff 100644 --- a/src/node/db/Pad.js +++ b/src/node/db/Pad.js @@ -476,26 +476,27 @@ Pad.prototype.copy = function copy(destinationID, force, callback) { // if it's a group pad, let's make sure the group exists. function(callback) { - if (destinationID.indexOf("$") != -1) + if (destinationID.indexOf("$") === -1) { - destGroupID = destinationID.split("$")[0] - groupManager.doesGroupExist(destGroupID, function (err, exists) - { - if(ERR(err, callback)) return; - - //group does not exist - if(exists == false) - { - callback(new customError("groupID does not exist for destinationID","apierror")); - return; - } - - //everything is fine, continue - callback(); - }); - } - else callback(); + return; + } + + destGroupID = destinationID.split("$")[0] + groupManager.doesGroupExist(destGroupID, function (err, exists) + { + if(ERR(err, callback)) return; + + //group does not exist + if(exists == false) + { + callback(new customError("groupID does not exist for destinationID","apierror")); + return; + } + + //everything is fine, continue + callback(); + }); }, // if the pad exists, we should abort, unless forced. function(callback)