mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-01-07 06:33:58 -06:00
SEARCH-444
- Created an api to clear the user index data folder
This commit is contained in:
parent
f2f1eb2cd6
commit
9e6a7df281
@ -119,32 +119,6 @@ class Crypto {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Deleting the data index folder
|
|
||||||
* when the app is closed
|
|
||||||
*/
|
|
||||||
deleteFolders() {
|
|
||||||
Crypto.deleteFolderRecursive(this.dataFolder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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()) {
|
|
||||||
Crypto.deleteFolderRecursive(curPath);
|
|
||||||
} else {
|
|
||||||
fs.unlinkSync(curPath);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
fs.rmdirSync(location);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Crypto;
|
module.exports = Crypto;
|
@ -18,8 +18,7 @@ const protocolHandler = require('./protocolHandler');
|
|||||||
const getCmdLineArg = require('./utils/getCmdLineArg.js');
|
const getCmdLineArg = require('./utils/getCmdLineArg.js');
|
||||||
const log = require('./log.js');
|
const log = require('./log.js');
|
||||||
const logLevels = require('./enums/logLevels.js');
|
const logLevels = require('./enums/logLevels.js');
|
||||||
const Crypto = require('./cryptoLib');
|
const { clearIndexFolder } = require('./search/search');
|
||||||
const crypto = new Crypto();
|
|
||||||
|
|
||||||
require('electron-dl')();
|
require('electron-dl')();
|
||||||
|
|
||||||
@ -132,7 +131,7 @@ app.on('activate', function() {
|
|||||||
|
|
||||||
app.on('will-quit', function (e) {
|
app.on('will-quit', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
crypto.deleteFolders();
|
clearIndexFolder();
|
||||||
app.exit();
|
app.exit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -136,6 +136,11 @@ function createAPI() {
|
|||||||
*/
|
*/
|
||||||
Search: remote.require('./search/search.js').Search,
|
Search: remote.require('./search/search.js').Search,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to clear the user index data
|
||||||
|
*/
|
||||||
|
clearIndexFolder: remote.require('./search/search.js').clearIndexFolder,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Brings window forward and gives focus.
|
* Brings window forward and gives focus.
|
||||||
* @param {String} windowName Name of window. Note: main window name is 'main'
|
* @param {String} windowName Name of window. Note: main window name is 'main'
|
||||||
|
@ -513,6 +513,33 @@ class Search {
|
|||||||
throw new Error(err);
|
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}}
|
* @type {{Search: Search}}
|
||||||
*/
|
*/
|
||||||
module.exports = {
|
module.exports = {
|
||||||
Search: Search
|
Search: Search,
|
||||||
|
clearIndexFolder: clearIndexFolder
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user