SEARCH-197

- Fixed a bug related to paths
This commit is contained in:
Keerthi Niranjan 2017-10-17 21:15:27 +05:30
parent a515ab3c35
commit e09e708111
2 changed files with 12 additions and 6 deletions

View File

@ -1,16 +1,22 @@
const child = require('child_process');
const isMac = require('../utils/misc.js').isMac;
const electron = require('electron');
const app = electron.app;
const path = require('path');
const userData = path.join(app.getPath('userData'));
const isDevEnv = require('../utils/misc.js').isDevEnv;
const DATA_FOLDER_PATH = isDevEnv ? path.join(__dirname, '..', '..') : userData;
function compression(pathToFolder, outputPath, cb) {
if (isMac) {
child.exec(`tar cvf - ${pathToFolder} | lz4 > ${outputPath}.tar.lz4`, (error, stdout) => {
child.exec(`cd "${DATA_FOLDER_PATH}" && tar cvf - "${pathToFolder}" | lz4 > "${outputPath}.tar.lz4"`, (error, stdout) => {
if (error) {
return cb(new Error(error));
}
return cb(null, stdout);
})
} else {
child.exec(`tar.exe -cvf - ${pathToFolder} | lz4.exe > ${outputPath}.tar.lz4`, (error, stdout) => {
child.exec(`cd "${DATA_FOLDER_PATH}" && tar.exe -cvf - "${pathToFolder}" | lz4.exe > "${outputPath}.tar.lz4"`, (error, stdout) => {
if (error) {
return cb(new Error(error));
}
@ -19,16 +25,16 @@ function compression(pathToFolder, outputPath, cb) {
}
}
function deCompression(path, cb) {
function deCompression(pathName, cb) {
if (isMac) {
child.exec(`lz4 -d ${path} | tar -xf -`, (error, stdout) => {
child.exec(`cd "${DATA_FOLDER_PATH}" && lz4 -d "${pathName}" | tar -xf - `, (error, stdout) => {
if (error) {
return cb(new Error(error));
}
return cb(null, stdout);
})
} else {
child.exec(`lz4.exe -d ${path} | tar.exe xf -`, (error, stdout) => {
child.exec(`cd "${DATA_FOLDER_PATH}" && lz4.exe -d "${pathName}" | tar.exe xf - `, (error, stdout) => {
if (error) {
return cb(new Error(error));
}

View File

@ -38,7 +38,7 @@ class Crypto {
return;
}
lz4.compression(`${this.indexDataFolder}`, `${this.dump}/${this.permanentIndexFolderName}`, (error) => {
lz4.compression(`data/${this.permanentIndexFolderName}`, `${this.permanentIndexFolderName}`, (error) => {
if (error) {
reject(error);
}