From bb3fc8f795e93ecbecfee955f02c060c563af4fe Mon Sep 17 00:00:00 2001 From: Keerthi Niranjan Date: Wed, 18 Oct 2017 16:01:51 +0530 Subject: [PATCH] SEARCH-197 - Windows fixes --- js/compressionLib/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/js/compressionLib/index.js b/js/compressionLib/index.js index 4d73f17b..3b0e5acd 100644 --- a/js/compressionLib/index.js +++ b/js/compressionLib/index.js @@ -7,6 +7,15 @@ const userData = path.join(app.getPath('userData')); const isDevEnv = require('../utils/misc.js').isDevEnv; const DATA_FOLDER_PATH = isDevEnv ? path.join(__dirname, '..', '..') : userData; +const execPath = path.dirname(app.getPath('exe')); + +// library path contractor +const folderLibPath = 'library'; +const productionPath = path.join(execPath, folderLibPath); +const devPath = path.join(__dirname, '..', '..', folderLibPath); + +const libraryPath = isDevEnv ? devPath : productionPath; + function compression(pathToFolder, outputPath, cb) { if (isMac) { child.exec(`cd "${DATA_FOLDER_PATH}" && tar cvf - "${pathToFolder}" | lz4 > "${outputPath}.tar.lz4"`, (error, stdout) => { @@ -16,7 +25,7 @@ function compression(pathToFolder, outputPath, cb) { return cb(null, stdout); }) } else { - child.exec(`cd "${DATA_FOLDER_PATH}" && library\\tar-win.exe cvf - "${pathToFolder}" | library\\lz4-win.exe > "${outputPath}.tar.lz4"`, (error, stdout) => { + child.exec(`cd "${DATA_FOLDER_PATH}" && "${libraryPath}\\tar-win.exe" cvf - "${pathToFolder}" | "${libraryPath}\\lz4-win.exe" > "${outputPath}.tar.lz4"`, (error, stdout) => { if (error) { return cb(new Error(error)); } @@ -34,7 +43,7 @@ function deCompression(pathName, cb) { return cb(null, stdout); }) } else { - child.exec(`cd "${DATA_FOLDER_PATH}" && library\\lz4-win.exe -d "${pathName}" | library\\tar-win.exe xf - `, (error, stdout) => { + child.exec(`cd "${DATA_FOLDER_PATH}" && "${libraryPath}\\lz4-win.exe" -d "${pathName}" | "${libraryPath}\\tar-win.exe" xf - `, (error, stdout) => { if (error) { return cb(new Error(error)); }