mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
Merge pull request #255 from keerthi16/SEARCH-535
SEARCH-535 (Deleting the index folder)
This commit is contained in:
commit
5c80064567
@ -71,8 +71,8 @@ class Search {
|
||||
init() {
|
||||
libSymphonySearch.symSEInit();
|
||||
libSymphonySearch.symSEEnsureFolderExists(this.dataFolder);
|
||||
libSymphonySearch.symSERemoveFolder(this.realTimeIndex);
|
||||
libSymphonySearch.symSERemoveFolder(this.batchIndex);
|
||||
Search.deleteIndexFolders(this.realTimeIndex);
|
||||
Search.deleteIndexFolders(this.batchIndex);
|
||||
Search.indexValidator(this.indexFolderName);
|
||||
Search.indexValidator(this.realTimeIndex);
|
||||
let indexDateStartFrom = new Date().getTime() - searchConfig.SEARCH_PERIOD_SUBTRACTOR;
|
||||
@ -139,7 +139,7 @@ class Search {
|
||||
reject(new Error(err));
|
||||
return;
|
||||
}
|
||||
libSymphonySearch.symSERemoveFolder(this.batchIndex);
|
||||
Search.deleteIndexFolders(this.batchIndex);
|
||||
resolve(res);
|
||||
});
|
||||
});
|
||||
@ -493,12 +493,12 @@ class Search {
|
||||
|
||||
let i,j = 0;
|
||||
let out = "";
|
||||
for(i = tokens.length; i>0; i--) {// number of tokens in a tuple
|
||||
for(j= 0; j < tokens.length-i+1 ; j++ ){ //start from index
|
||||
if(out != ""){
|
||||
for(i = tokens.length; i > 0; i--) {// number of tokens in a tuple
|
||||
for(j = 0; j < tokens.length-i + 1 ; j++){ //start from index
|
||||
if(out !== ""){
|
||||
out += " ";
|
||||
}
|
||||
out += Search.putTokensInRange(tokens, j, i);
|
||||
out += Search.putTokensInRange(tokens, j, i);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
@ -514,10 +514,9 @@ class Search {
|
||||
* @returns {String}
|
||||
*/
|
||||
static putTokensInRange(tokens, start, numTokens) {
|
||||
let i=0;
|
||||
let out = "\"";
|
||||
for(i=0; i< numTokens; i++) {
|
||||
if(i != 0) {
|
||||
for(let i = 0; i < numTokens; i++) {
|
||||
if(i !== 0) {
|
||||
out += " ";
|
||||
}
|
||||
out+= tokens[start+i];
|
||||
@ -550,12 +549,12 @@ class Search {
|
||||
* Removing all the folders and files inside the data folder
|
||||
* @param location
|
||||
*/
|
||||
static deleteFolderRecursive(location) {
|
||||
static deleteIndexFolders(location) {
|
||||
if (fs.existsSync(location)) {
|
||||
fs.readdirSync(location).forEach((file) => {
|
||||
let curPath = location + "/" + file;
|
||||
if (fs.lstatSync(curPath).isDirectory()) {
|
||||
Search.deleteFolderRecursive(curPath);
|
||||
Search.deleteIndexFolders(curPath);
|
||||
} else {
|
||||
fs.unlinkSync(curPath);
|
||||
}
|
||||
@ -571,7 +570,7 @@ class Search {
|
||||
* when the app is closed/signed-out/navigates
|
||||
*/
|
||||
function deleteIndexFolder() {
|
||||
Search.deleteFolderRecursive(searchConfig.FOLDERS_CONSTANTS.INDEX_PATH);
|
||||
Search.deleteIndexFolders(searchConfig.FOLDERS_CONSTANTS.INDEX_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user