SEARCH-444

- Implemented a function to delete the index folder
This commit is contained in:
Keerthi Niranjan 2017-11-24 15:58:01 +05:30
parent 384b114670
commit 222e52cbdf
4 changed files with 12 additions and 6 deletions

View File

@ -18,7 +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 { clearIndexFolder } = require('./search/search'); const { deleteIndexFolder } = require('./search/search.js');
require('electron-dl')(); require('electron-dl')();
@ -131,7 +131,7 @@ app.on('activate', function() {
app.on('will-quit', function (e) { app.on('will-quit', function (e) {
e.preventDefault(); e.preventDefault();
clearIndexFolder(); deleteIndexFolder();
app.exit(); app.exit();
}); });

View File

@ -139,7 +139,7 @@ function createAPI() {
/** /**
* Function to clear the user index data * Function to clear the user index data
*/ */
clearIndexFolder: remote.require('./search/search.js').clearIndexFolder, deleteIndexFolder: remote.require('./search/search.js').deleteIndexFolder,
/** /**
* Brings window forward and gives focus. * Brings window forward and gives focus.

View File

@ -538,9 +538,9 @@ class Search {
/** /**
* Deleting the data index folder * Deleting the data index folder
* when the app is closed * when the app is closed/signed-out/navigates
*/ */
function clearIndexFolder() { function deleteIndexFolder() {
Search.deleteFolderRecursive(INDEX_DATA_FOLDER); Search.deleteFolderRecursive(INDEX_DATA_FOLDER);
} }
@ -550,5 +550,5 @@ function clearIndexFolder() {
*/ */
module.exports = { module.exports = {
Search: Search, Search: Search,
clearIndexFolder: clearIndexFolder deleteIndexFolder: deleteIndexFolder
}; };

View File

@ -20,6 +20,7 @@ const eventEmitter = require('./eventEmitter');
const throttle = require('./utils/throttle.js'); const throttle = require('./utils/throttle.js');
const { getConfigField, updateConfigField } = require('./config.js'); const { getConfigField, updateConfigField } = require('./config.js');
const { isMac, isNodeEnv } = require('./utils/misc'); const { isMac, isNodeEnv } = require('./utils/misc');
const { deleteIndexFolder } = require('./search/search.js');
// show dialog when certificate errors occur // show dialog when certificate errors occur
require('./dialogs/showCertError.js'); require('./dialogs/showCertError.js');
@ -256,6 +257,11 @@ function doCreateMainWindow(initialUrl, initialBounds) {
}); });
}); });
// To delete the user index data folder on navigation
mainWindow.webContents.on('will-navigate', () => {
deleteIndexFolder();
});
getConfigField('url') getConfigField('url')
.then(initializeCrashReporter) .then(initializeCrashReporter)
.catch(app.quit); .catch(app.quit);