Merge pull request #301 from keerthi16/SEARCH-605-new

SEARCH-605 (Electron - Cannot enable swift search on Windows 7)
This commit is contained in:
Vikas Shashidhar 2018-02-16 15:38:47 +05:30 committed by GitHub
commit f23ed615a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 11 deletions

View File

@ -58,7 +58,10 @@ const searchConfig = {
FOLDERS_CONSTANTS: folderPaths,
TAR_LZ4_EXT: '.tar.lz4',
RANDOM_STRING: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
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;

View File

@ -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));
}
@ -25,13 +25,21 @@ function checkDiskSpace(path, resolve, reject) {
return resolve(space >= searchConfig.MINIMUM_DISK_SPACE);
});
} else {
exec(`fsutil volume diskfree ${path}`, (error, stdout, stderr) => {
exec(`fsutil volume diskfree ${path}`, (error, stdout) => {
if (error) {
if (stderr.indexOf("No such file or directory") !== -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(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(searchConfig.PERMISSION_ERROR) !== -1) {
// this is temporary until we use the custom exe file.
return resolve(true);
}
let data = stdout.trim().split("\n");
let disk_info_str = data[data.length - 1].split(':');

View File

@ -1,7 +1,7 @@
const childProcess = require('child_process');
const path = require('path');
const fs = require('fs');
const { isMac } = require('../js/utils/misc.js');
const { isWindowsOS } = require('../js/utils/misc.js');
let executionPath = null;
let userConfigDir = null;
@ -46,7 +46,7 @@ describe('Tests for Search', function() {
key = 'jjjehdnctsjyieoalskcjdhsnahsadndfnusdfsdfsd=';
executionPath = path.join(__dirname, 'library');
if (!isMac) {
if (isWindowsOS) {
executionPath = path.join(__dirname, '..', 'library');
}
userConfigDir = path.join(__dirname, '..');
@ -59,7 +59,7 @@ describe('Tests for Search', function() {
tempBatchPath = path.join(userConfigDir, 'data', 'temp_batch_indexes');
dataFolderPath = path.join(userConfigDir, 'data');
if (fs.existsSync(dataFolderPath)) {
fs.unlinkSync(dataFolderPath)
deleteIndexFolders(dataFolderPath)
}
done();
});

View File

@ -1,6 +1,6 @@
const fs = require('fs');
const path = require('path');
const { isMac } = require('../js/utils/misc.js');
const { isMac, isWindowsOS } = require('../js/utils/misc.js');
let executionPath = null;
let userConfigDir = null;
@ -33,6 +33,9 @@ describe('Tests for Search Utils', function() {
beforeAll(function (done) {
executionPath = path.join(__dirname, 'library');
if (isWindowsOS) {
executionPath = path.join(__dirname, '..', 'library');
}
userConfigDir = path.join(__dirname, '..');
searchConfig = require('../js/search/searchConfig.js');
const { SearchUtils } = require('../js/search/searchUtils.js');
@ -81,7 +84,7 @@ describe('Tests for Search Utils', function() {
it('should return error invalid path', function (done) {
const checkFreeSpace = jest.spyOn(SearchUtilsAPI, 'checkFreeSpace');
SearchUtilsAPI.path = './tp';
if (!isMac) {
if (isWindowsOS) {
SearchUtilsAPI.path = 'A://test';
}
SearchUtilsAPI.checkFreeSpace().catch(function (err) {