mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
SEARCH-444
- Created an api to clear the user index data folder
This commit is contained in:
@@ -513,6 +513,33 @@ class Search {
|
||||
throw new Error(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removing all the folders and files inside the data folder
|
||||
* @param location
|
||||
*/
|
||||
static deleteFolderRecursive(location) {
|
||||
if (fs.existsSync(location)) {
|
||||
fs.readdirSync(location).forEach((file) => {
|
||||
let curPath = location + "/" + file;
|
||||
if (fs.lstatSync(curPath).isDirectory()) {
|
||||
Search.deleteFolderRecursive(curPath);
|
||||
} else {
|
||||
fs.unlinkSync(curPath);
|
||||
}
|
||||
});
|
||||
fs.rmdirSync(location);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Deleting the data index folder
|
||||
* when the app is closed
|
||||
*/
|
||||
function clearIndexFolder() {
|
||||
Search.deleteFolderRecursive(INDEX_DATA_FOLDER);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -520,5 +547,6 @@ class Search {
|
||||
* @type {{Search: Search}}
|
||||
*/
|
||||
module.exports = {
|
||||
Search: Search
|
||||
Search: Search,
|
||||
clearIndexFolder: clearIndexFolder
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user