mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-20 11:48:30 -06:00
SEARCH-621 (New exe for checking disk space) (#315)
- Implements new exe from the utils library - Update AIP - Increase utils version
This commit is contained in:
parent
c3b82a0869
commit
944eb389ba
@ -33,6 +33,8 @@ const launchAgentFile = path.join(libraryFolderPath, 'search-launch-agent.sh');
|
|||||||
const launchDaemonFile = path.join(libraryFolderPath, 'search-launch-daemon.sh');
|
const launchDaemonFile = path.join(libraryFolderPath, 'search-launch-daemon.sh');
|
||||||
const windowsTaskFile = path.join(pathToUtils, isDevEnv ? 'ClearSchTasks/bin/Release/ClearSchTasks.exe' : 'ClearSchTasks.exe');
|
const windowsTaskFile = path.join(pathToUtils, isDevEnv ? 'ClearSchTasks/bin/Release/ClearSchTasks.exe' : 'ClearSchTasks.exe');
|
||||||
const windowsClearScript = path.join(pathToUtils, isDevEnv ? 'ClearOnBoot/bin/Release/ClearOnBoot.exe' : 'ClearOnBoot.exe');
|
const windowsClearScript = path.join(pathToUtils, isDevEnv ? 'ClearOnBoot/bin/Release/ClearOnBoot.exe' : 'ClearOnBoot.exe');
|
||||||
|
const freeDiskSpace = path.join(pathToUtils, isDevEnv ? 'FreeDiskSpace/bin/Release/FreeDiskSpace.exe' : 'FreeDiskSpace.exe');
|
||||||
|
|
||||||
|
|
||||||
const libraryPaths = {
|
const libraryPaths = {
|
||||||
INDEX_VALIDATOR: indexValidatorPath,
|
INDEX_VALIDATOR: indexValidatorPath,
|
||||||
@ -45,6 +47,7 @@ const libraryPaths = {
|
|||||||
LAUNCH_DAEMON_FILE: launchDaemonFile,
|
LAUNCH_DAEMON_FILE: launchDaemonFile,
|
||||||
WINDOWS_TASK_FILE: windowsTaskFile,
|
WINDOWS_TASK_FILE: windowsTaskFile,
|
||||||
WINDOWS_CLEAR_SCRIPT: windowsClearScript,
|
WINDOWS_CLEAR_SCRIPT: windowsClearScript,
|
||||||
|
FREE_DISK_SPACE: freeDiskSpace,
|
||||||
};
|
};
|
||||||
|
|
||||||
const folderPaths = {
|
const folderPaths = {
|
||||||
@ -70,6 +73,8 @@ const searchConfig = {
|
|||||||
LIBRARY_CONSTANTS: libraryPaths,
|
LIBRARY_CONSTANTS: libraryPaths,
|
||||||
FOLDERS_CONSTANTS: folderPaths,
|
FOLDERS_CONSTANTS: folderPaths,
|
||||||
TAR_LZ4_EXT: '.tar.lz4',
|
TAR_LZ4_EXT: '.tar.lz4',
|
||||||
|
DISK_NOT_READY: 'NOT_READY',
|
||||||
|
DISK_NOT_FOUND: 'DISK_NOT_FOUND',
|
||||||
RANDOM_STRING: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
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.",
|
PERMISSION_ERROR: "The FSUTIL utility requires that you have administrative privileges.",
|
||||||
|
@ -22,7 +22,7 @@ class SearchUtils {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!isMac) {
|
if (!isMac) {
|
||||||
try {
|
try {
|
||||||
this.path = this.path.substring(0, 2);
|
this.path = this.path.substring(0, 1);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
reject(new Error('Invalid Path : ' + e));
|
reject(new Error('Invalid Path : ' + e));
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
const { exec } = require('child_process');
|
const { exec } = require('child_process');
|
||||||
const { isMac } = require('../../utils/misc');
|
const { isMac } = require('../../utils/misc');
|
||||||
const searchConfig = require('../searchConfig.js');
|
const searchConfig = require('../searchConfig.js');
|
||||||
|
const log = require('../../log.js');
|
||||||
|
const logLevels = require('../../enums/logLevels.js');
|
||||||
|
|
||||||
function checkDiskSpace(path, resolve, reject) {
|
function checkDiskSpace(path, resolve, reject) {
|
||||||
if (!path) {
|
if (!path) {
|
||||||
@ -25,25 +27,25 @@ function checkDiskSpace(path, resolve, reject) {
|
|||||||
return resolve(space >= searchConfig.MINIMUM_DISK_SPACE);
|
return resolve(space >= searchConfig.MINIMUM_DISK_SPACE);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
exec(`fsutil volume diskfree ${path}`, (error, stdout) => {
|
exec(`"${searchConfig.LIBRARY_CONSTANTS.FREE_DISK_SPACE}" ${path}`, (error, stdout, stderr) => {
|
||||||
if (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(':');
|
if (error) {
|
||||||
return resolve(disk_info_str[1] >= searchConfig.MINIMUM_DISK_SPACE);
|
log.send(logLevels.ERROR, `Error retrieving free disk space : ${error}`);
|
||||||
|
log.send(logLevels.ERROR, `Error stderr: ${stderr}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
let data = stdout.trim().split(",");
|
||||||
|
|
||||||
|
if (data[ 1 ] === searchConfig.DISK_NOT_READY) {
|
||||||
|
return reject(new Error("Error : Disk not ready"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data[ 1 ] === searchConfig.DISK_NOT_FOUND) {
|
||||||
|
return reject(new Error("Error : Disk not found"));
|
||||||
|
}
|
||||||
|
|
||||||
|
let disk_info_str = data[ 0 ];
|
||||||
|
return resolve(disk_info_str >= searchConfig.MINIMUM_DISK_SPACE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user