From 12bb97dc2d012fb5fe4f3e17855af39527a27701 Mon Sep 17 00:00:00 2001 From: muxator Date: Wed, 31 Oct 2018 23:24:56 +0100 Subject: [PATCH] ImportHandler: early return by condition inversion No functional changes --- src/node/handler/ImportHandler.js | 36 ++++++++++++++++--------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/node/handler/ImportHandler.js b/src/node/handler/ImportHandler.js index 02975e2be..5817928ef 100644 --- a/src/node/handler/ImportHandler.js +++ b/src/node/handler/ImportHandler.js @@ -227,25 +227,27 @@ exports.doImport = function(req, res, padId) //read the text function(callback) { - if(!directDatabaseAccess){ - fs.readFile(destFile, "utf8", function(err, _text){ - if(ERR(err, callback)) return; - text = _text; - // Title needs to be stripped out else it appends it to the pad.. - text = text.replace("", "<!-- <title>"); - text = text.replace("","-->"); - - //node on windows has a delay on releasing of the file lock. - //We add a 100ms delay to work around this - if(os.type().indexOf("Windows") > -1){ - setTimeout(function() {callback();}, 100); - } else { - callback(); - } - }); - }else{ + if (directDatabaseAccess) { callback(); + + return; } + + fs.readFile(destFile, "utf8", function(err, _text){ + if(ERR(err, callback)) return; + text = _text; + // Title needs to be stripped out else it appends it to the pad.. + text = text.replace("", "<!-- <title>"); + text = text.replace("","-->"); + + //node on windows has a delay on releasing of the file lock. + //We add a 100ms delay to work around this + if(os.type().indexOf("Windows") > -1){ + setTimeout(function() {callback();}, 100); + } else { + callback(); + } + }); }, //change text of the pad and broadcast the changeset