From 48fe7a6fbedcd1bfb400a99ab5a9f313b81e0910 Mon Sep 17 00:00:00 2001 From: Keerthi Niranjan Date: Fri, 16 Feb 2018 13:32:50 +0530 Subject: [PATCH] SEARCH-605 - Review comments fix --- js/search/searchConfig.js | 5 ++++- js/search/utils/checkDiskSpace.js | 12 ++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/js/search/searchConfig.js b/js/search/searchConfig.js index 7d424bdc..170c7582 100644 --- a/js/search/searchConfig.js +++ b/js/search/searchConfig.js @@ -57,7 +57,10 @@ const searchConfig = { LIBRARY_CONSTANTS: libraryPaths, FOLDERS_CONSTANTS: folderPaths, TAR_LZ4_EXT: '.tar.lz4', - MINIMUM_DISK_SPACE: 300000000 // in bytes + MINIMUM_DISK_SPACE: 300000000, // in bytes + PERMISSION_ERROR: "The FSUTIL utility requires that you have administrative privileges.", + WIN_PATH_ERROR: "Error: The system cannot find the path specified.", + MAC_PATH_ERROR: "No such file or directory" }; module.exports = searchConfig; diff --git a/js/search/utils/checkDiskSpace.js b/js/search/utils/checkDiskSpace.js index 78aba530..84a9f8be 100644 --- a/js/search/utils/checkDiskSpace.js +++ b/js/search/utils/checkDiskSpace.js @@ -11,8 +11,8 @@ function checkDiskSpace(path, resolve, reject) { if (isMac) { exec("df -k '" + path.replace(/'/g,"'\\''") + "'", (error, stdout, stderr) => { if (error) { - if (stderr.indexOf("No such file or directory") !== -1) { - return reject(new Error("No such file or directory : " + error)) + if (stderr.indexOf(searchConfig.MAC_PATH_ERROR) !== -1) { + return reject(new Error(`${searchConfig.MAC_PATH_ERROR} ${error}`)) } return reject(new Error("Error : " + error)); } @@ -27,16 +27,16 @@ function checkDiskSpace(path, resolve, reject) { } else { exec(`fsutil volume diskfree ${path}`, (error, stdout) => { if (error) { - if (stdout.indexOf("Error: The system cannot find the path specified.") !== -1) { - return reject(new Error("No such file or directory : " + error)); + if (stdout.indexOf(searchConfig.WIN_PATH_ERROR) !== -1) { + return reject(new Error(`${searchConfig.WIN_PATH_ERROR} ${error}`)); } - if (stdout.indexOf("The FSUTIL utility requires that you have administrative privileges.") !== -1) { + if (stdout.indexOf(searchConfig.PERMISSION_ERROR) !== -1) { // this is temporary until we use the custom exe file. return resolve(true); } return reject(new Error("Error : " + error)); } - if (stdout.indexOf("The FSUTIL utility requires that you have administrative privileges.") !== -1) { + if (stdout.indexOf(searchConfig.PERMISSION_ERROR) !== -1) { // this is temporary until we use the custom exe file. return resolve(true); }