mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
* SEARCH-627 & SEARCH-628 - Add implementation for memory indexing - Batch indexing and Real-time indexing * ELECTRON-426 (#345) - Changes innerHTML to innerText - Removes 'replaceStrongTag' and 'replaceHTMLTags' function and changing to innerHTML to innerText * SEARCH-764 - Rework "deleteIndexFolders" in the Electron Preload Script - Fixes the Security Vulnerability * SEARCH-764 - Updates spectron test preload api version * SEARCH-766 - Rework "readFile" in Electron Preload Script - Removing this method as this is only for the demo app * SEARCH-766 - Removes merge method * SEARCH-767 - Rework "path" in Electron Preload Script - Removes the constructor to use hardcoded path * SEARCH-767 - Updates unit test * SEARCH-775 - Adds search api version to match with the client app * SEARCH-775 - Spectron test fix * SEARCH-770 (#391) - constructor is required which was removed as part of SEARCH-767
85 lines
3.7 KiB
JavaScript
85 lines
3.7 KiB
JavaScript
const electron = require('electron');
|
|
const app = electron.app;
|
|
const path = require('path');
|
|
const userData = path.join(app.getPath('userData'));
|
|
const execPath = path.dirname(app.getPath('exe'));
|
|
const { isDevEnv, isMac } = require('../utils/misc.js');
|
|
|
|
const INDEX_FOLDER_NAME = 'data';
|
|
|
|
const winLibraryPath = isDevEnv ? path.join(__dirname, '..', '..', 'library') : path.join(execPath, 'library');
|
|
const macLibraryPath = isDevEnv ? path.join(__dirname, '..', '..', 'library') : path.join(execPath, '..', 'library');
|
|
|
|
const arch = process.arch === 'ia32';
|
|
|
|
const winIndexValidatorArch = arch ? 'indexvalidator-x86.exe' : 'indexvalidator-x64.exe';
|
|
const indexValidatorPath = isMac ? path.join(macLibraryPath, 'indexvalidator.exec') : path.join(winLibraryPath, winIndexValidatorArch);
|
|
|
|
const winLZ4ArchPath = arch ? 'lz4-win-x86.exe' : 'lz4-win-x64.exe';
|
|
const lz4Path = path.join(winLibraryPath, winLZ4ArchPath);
|
|
|
|
const indexFolderPath = isDevEnv ? `./${INDEX_FOLDER_NAME}` : path.join(userData, INDEX_FOLDER_NAME);
|
|
|
|
const winSearchLibArchPath = arch ? 'libsymphonysearch-x86.dll' : 'libsymphonysearch-x64.dll';
|
|
const libraryPath = isMac ? path.join(macLibraryPath, 'libsymphonysearch.dylib') : path.join(winLibraryPath, winSearchLibArchPath);
|
|
|
|
const userConfigFileName = 'search_users_config.json';
|
|
const userConfigFile = isDevEnv ? path.join(__dirname, '..', '..', userConfigFileName) : path.join(userData, userConfigFileName);
|
|
|
|
const libraryFolderPath = isMac ? macLibraryPath : winLibraryPath;
|
|
|
|
const pathToUtils = isDevEnv ? path.join(__dirname, '../../node_modules/electron-utils') : winLibraryPath;
|
|
const launchAgentFile = path.join(libraryFolderPath, 'search-launch-agent.sh');
|
|
const launchDaemonFile = path.join(libraryFolderPath, 'search-launch-daemon.sh');
|
|
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 freeDiskSpace = path.join(pathToUtils, isDevEnv ? 'FreeDiskSpace/bin/Release/FreeDiskSpace.exe' : 'FreeDiskSpace.exe');
|
|
|
|
|
|
const libraryPaths = {
|
|
INDEX_VALIDATOR: indexValidatorPath,
|
|
LZ4_PATH: lz4Path,
|
|
MAC_LIBRARY_FOLDER: macLibraryPath,
|
|
WIN_LIBRARY_FOLDER: winLibraryPath,
|
|
SEARCH_LIBRARY_PATH: libraryPath,
|
|
LIBRARY_FOLDER_PATH: libraryFolderPath,
|
|
LAUNCH_AGENT_FILE: launchAgentFile,
|
|
LAUNCH_DAEMON_FILE: launchDaemonFile,
|
|
WINDOWS_TASK_FILE: windowsTaskFile,
|
|
WINDOWS_CLEAR_SCRIPT: windowsClearScript,
|
|
FREE_DISK_SPACE: freeDiskSpace,
|
|
};
|
|
|
|
const folderPaths = {
|
|
INDEX_PATH: indexFolderPath,
|
|
TEMP_BATCH_INDEX_FOLDER: indexFolderPath + '/temp_batch_indexes',
|
|
PREFIX_NAME: 'search_index',
|
|
PREFIX_NAME_PATH: indexFolderPath + '/search_index',
|
|
EXEC_PATH: execPath,
|
|
USER_DATA_PATH: userData,
|
|
INDEX_FOLDER_NAME: INDEX_FOLDER_NAME,
|
|
USER_CONFIG_FILE: userConfigFile
|
|
};
|
|
|
|
const searchConfig = {
|
|
SEARCH_PERIOD_SUBTRACTOR: 3 * 31 * 24 * 60 * 60 * 1000,
|
|
REAL_TIME_INDEXING_TIME: 60000,
|
|
MINIMUM_DATE: '0000000000000',
|
|
MAXIMUM_DATE: '9999999999999',
|
|
SORT_BY_SCORE: 0,
|
|
INDEX_VERSION: 'v1',
|
|
BATCH_RANDOM_INDEX_PATH_LENGTH: 20,
|
|
LIBRARY_CONSTANTS: libraryPaths,
|
|
FOLDERS_CONSTANTS: folderPaths,
|
|
TAR_LZ4_EXT: '.tar.lz4',
|
|
DISK_NOT_READY: 'NOT_READY',
|
|
DISK_NOT_FOUND: 'DISK_NOT_FOUND',
|
|
RANDOM_STRING: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
|
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;
|