From 603d74c5b9c1ddd321b30ecd1ba1b4866bc98c21 Mon Sep 17 00:00:00 2001 From: Keerthi Niranjan Date: Tue, 9 Jan 2018 16:16:59 +0530 Subject: [PATCH] SEARCH-569 - Removing the version information from user index folder --- js/cryptoLib/index.js | 4 ++-- js/search/search.js | 2 +- js/search/searchConfig.js | 1 - tests/Search.test.js | 6 +++--- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/js/cryptoLib/index.js b/js/cryptoLib/index.js index 6a393328..59e7f80e 100644 --- a/js/cryptoLib/index.js +++ b/js/cryptoLib/index.js @@ -18,8 +18,8 @@ class Crypto { * @param key */ constructor(userId, key) { - this.indexDataFolder = `${searchConfig.FOLDERS_CONSTANTS.PREFIX_NAME_PATH}_${userId}_${searchConfig.INDEX_VERSION}`; - this.permanentIndexName = `${searchConfig.FOLDERS_CONSTANTS.PREFIX_NAME}_${userId}_${searchConfig.INDEX_VERSION}`; + this.indexDataFolder = `${searchConfig.FOLDERS_CONSTANTS.PREFIX_NAME_PATH}_${userId}`; + this.permanentIndexName = `${searchConfig.FOLDERS_CONSTANTS.PREFIX_NAME}_${userId}`; this.dump = DUMP_PATH; this.key = key; this.encryptedIndex = `${DUMP_PATH}/${this.permanentIndexName}.enc`; diff --git a/js/search/search.js b/js/search/search.js index d394990b..49d05ff1 100644 --- a/js/search/search.js +++ b/js/search/search.js @@ -31,7 +31,7 @@ class Search { this.isInitialized = false; this.userId = userId; this.key = key; - this.indexFolderName = `${searchConfig.FOLDERS_CONSTANTS.PREFIX_NAME_PATH}_${this.userId}_${searchConfig.INDEX_VERSION}`; + this.indexFolderName = `${searchConfig.FOLDERS_CONSTANTS.PREFIX_NAME_PATH}_${this.userId}`; this.dataFolder = searchConfig.FOLDERS_CONSTANTS.INDEX_PATH; this.realTimeIndex = searchConfig.FOLDERS_CONSTANTS.TEMP_REAL_TIME_INDEX; this.batchIndex = searchConfig.FOLDERS_CONSTANTS.TEMP_BATCH_INDEX_FOLDER; diff --git a/js/search/searchConfig.js b/js/search/searchConfig.js index 9be1bf89..3f38ad64 100644 --- a/js/search/searchConfig.js +++ b/js/search/searchConfig.js @@ -51,7 +51,6 @@ const searchConfig = { REAL_TIME_INDEXING_TIME: 60000, MINIMUM_DATE: '0000000000000', MAXIMUM_DATE: '9999999999999', - INDEX_VERSION: 'v1', SORT_BY_SCORE: 0, BATCH_RANDOM_INDEX_PATH_LENGTH: 20, LIBRARY_CONSTANTS: libraryPaths, diff --git a/tests/Search.test.js b/tests/Search.test.js index 637afd42..9e8d7dd1 100644 --- a/tests/Search.test.js +++ b/tests/Search.test.js @@ -63,7 +63,7 @@ describe('Tests for Search', function() { setTimeout(function () { deleteIndexFolders(dataFolderPath); - let root = path.join(searchConfig.FOLDERS_CONSTANTS.EXEC_PATH, '..', `${searchConfig.FOLDERS_CONSTANTS.PREFIX_NAME}_${userId}_${searchConfig.INDEX_VERSION}.enc`); + let root = path.join(searchConfig.FOLDERS_CONSTANTS.EXEC_PATH, '..', `${searchConfig.FOLDERS_CONSTANTS.PREFIX_NAME}_${userId}.enc`); if (fs.existsSync(root)) { fs.unlinkSync(root); } @@ -92,7 +92,7 @@ describe('Tests for Search', function() { setTimeout(function () { expect(SearchApi.isInitialized).toBe(true); - expect(SearchApi.indexFolderName).toBe(`${searchConfig.FOLDERS_CONSTANTS.PREFIX_NAME_PATH}_${userId}_${searchConfig.INDEX_VERSION}`); + expect(SearchApi.indexFolderName).toBe(`${searchConfig.FOLDERS_CONSTANTS.PREFIX_NAME_PATH}_${userId}`); expect(SearchApi.dataFolder).toBe(searchConfig.FOLDERS_CONSTANTS.INDEX_PATH); expect(SearchApi.realTimeIndex).toBe(searchConfig.FOLDERS_CONSTANTS.TEMP_REAL_TIME_INDEX); expect(SearchApi.batchIndex).toBe(searchConfig.FOLDERS_CONSTANTS.TEMP_BATCH_INDEX_FOLDER); @@ -423,7 +423,7 @@ describe('Tests for Search', function() { const getLatestMessageTimestamp = jest.spyOn(SearchApi, 'getLatestMessageTimestamp'); SearchApi.getLatestMessageTimestamp().catch(function (err) { expect(err).toEqual(new Error('Index folder does not exist.')); - SearchApi.indexFolderName = `${dataFolderPath}/${searchConfig.FOLDERS_CONSTANTS.PREFIX_NAME}_${userId}_${searchConfig.INDEX_VERSION}`; + SearchApi.indexFolderName = `${dataFolderPath}/${searchConfig.FOLDERS_CONSTANTS.PREFIX_NAME}_${userId}`; expect(getLatestMessageTimestamp).toHaveBeenCalled(); expect(getLatestMessageTimestamp).toHaveBeenCalledTimes(3); done();