From fa0bdd7b1ad88ad14c92bea1bcbcec4f94fa4924 Mon Sep 17 00:00:00 2001 From: FinnHornhoover Date: Mon, 13 Nov 2023 20:05:02 +0300 Subject: [PATCH] fixed hash check timing on config change --- assets/js/server-selector.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/assets/js/server-selector.js b/assets/js/server-selector.js index 75bde75..4e4a6ad 100644 --- a/assets/js/server-selector.js +++ b/assets/js/server-selector.js @@ -302,17 +302,17 @@ function editConfig() { jsonToModify["verify-offline-cache"] = $("#editconfig-verifyofflinecache").prop("checked"); var dirInput = $("#editconfig-offlinecachelocation:text").val(); - - jsonToModify["offline-cache-location"] = ( + var shouldChangeRoot = ( remotefs.existsSync(dirInput) && remotefs.statSync(dirInput).isDirectory() - ) ? dirInput : offlineRoot; + ); + + jsonToModify["offline-cache-location"] = shouldChangeRoot ? dirInput : offlineRoot; remotefs.writeFileSync(configPath, JSON.stringify(jsonToModify, null, 4)); - if (jsonToModify["offline-cache-location"] !== offlineRoot) - handleCache("hash-check"); loadConfig(); + if (shouldChangeRoot) handleCache("hash-check"); } function validateCacheLocation() {