diff --git a/js/cryptoLib/index.js b/js/cryptoLib/index.js index b300c3cb..6b14b22a 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.key = key; this.encryptedIndex = `${DUMP_PATH}/${this.permanentIndexName}.enc`; this.dataFolder = searchConfig.FOLDERS_CONSTANTS.INDEX_PATH; diff --git a/js/search/search.js b/js/search/search.js index 8df13a32..01886f04 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 9ebf7b17..3ea02e21 100644 --- a/tests/Search.test.js +++ b/tests/Search.test.js @@ -65,7 +65,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); } @@ -94,7 +94,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); @@ -118,7 +118,7 @@ describe('Tests for Search', function() { }); it('should exist index folder', function() { - expect(fs.existsSync(path.join(userConfigDir, 'data', 'search_index_12345678910112_v1'))).toBe(true); + expect(fs.existsSync(path.join(userConfigDir, 'data', 'search_index_12345678910112'))).toBe(true); expect(fs.existsSync(realTimeIndexPath)).toBe(true); }); @@ -390,8 +390,8 @@ describe('Tests for Search', function() { it('should exist encrypted file', function (done) { setTimeout(function () { - expect(fs.existsSync(path.join(userConfigDir, 'search_index_12345678910112_v1.enc'))).toBe(true); - expect(fs.existsSync(path.join(userConfigDir, 'search_index_12345678910112_v1.tar.lz4'))).toBe(false); + expect(fs.existsSync(path.join(userConfigDir, 'search_index_12345678910112.enc'))).toBe(true); + expect(fs.existsSync(path.join(userConfigDir, 'search_index_12345678910112.tar.lz4'))).toBe(false); done(); }, 3000); @@ -425,7 +425,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();