SEARCH-569

- Removing the version information from user index folder
This commit is contained in:
Keerthi Niranjan 2018-01-09 16:16:59 +05:30
parent d3f6877b7a
commit 603d74c5b9
4 changed files with 6 additions and 7 deletions

View File

@ -18,8 +18,8 @@ class Crypto {
* @param key * @param key
*/ */
constructor(userId, key) { constructor(userId, key) {
this.indexDataFolder = `${searchConfig.FOLDERS_CONSTANTS.PREFIX_NAME_PATH}_${userId}_${searchConfig.INDEX_VERSION}`; this.indexDataFolder = `${searchConfig.FOLDERS_CONSTANTS.PREFIX_NAME_PATH}_${userId}`;
this.permanentIndexName = `${searchConfig.FOLDERS_CONSTANTS.PREFIX_NAME}_${userId}_${searchConfig.INDEX_VERSION}`; this.permanentIndexName = `${searchConfig.FOLDERS_CONSTANTS.PREFIX_NAME}_${userId}`;
this.dump = DUMP_PATH; this.dump = DUMP_PATH;
this.key = key; this.key = key;
this.encryptedIndex = `${DUMP_PATH}/${this.permanentIndexName}.enc`; this.encryptedIndex = `${DUMP_PATH}/${this.permanentIndexName}.enc`;

View File

@ -31,7 +31,7 @@ class Search {
this.isInitialized = false; this.isInitialized = false;
this.userId = userId; this.userId = userId;
this.key = key; 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.dataFolder = searchConfig.FOLDERS_CONSTANTS.INDEX_PATH;
this.realTimeIndex = searchConfig.FOLDERS_CONSTANTS.TEMP_REAL_TIME_INDEX; this.realTimeIndex = searchConfig.FOLDERS_CONSTANTS.TEMP_REAL_TIME_INDEX;
this.batchIndex = searchConfig.FOLDERS_CONSTANTS.TEMP_BATCH_INDEX_FOLDER; this.batchIndex = searchConfig.FOLDERS_CONSTANTS.TEMP_BATCH_INDEX_FOLDER;

View File

@ -51,7 +51,6 @@ const searchConfig = {
REAL_TIME_INDEXING_TIME: 60000, REAL_TIME_INDEXING_TIME: 60000,
MINIMUM_DATE: '0000000000000', MINIMUM_DATE: '0000000000000',
MAXIMUM_DATE: '9999999999999', MAXIMUM_DATE: '9999999999999',
INDEX_VERSION: 'v1',
SORT_BY_SCORE: 0, SORT_BY_SCORE: 0,
BATCH_RANDOM_INDEX_PATH_LENGTH: 20, BATCH_RANDOM_INDEX_PATH_LENGTH: 20,
LIBRARY_CONSTANTS: libraryPaths, LIBRARY_CONSTANTS: libraryPaths,

View File

@ -63,7 +63,7 @@ describe('Tests for Search', function() {
setTimeout(function () { setTimeout(function () {
deleteIndexFolders(dataFolderPath); 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)) { if (fs.existsSync(root)) {
fs.unlinkSync(root); fs.unlinkSync(root);
} }
@ -92,7 +92,7 @@ describe('Tests for Search', function() {
setTimeout(function () { setTimeout(function () {
expect(SearchApi.isInitialized).toBe(true); 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.dataFolder).toBe(searchConfig.FOLDERS_CONSTANTS.INDEX_PATH);
expect(SearchApi.realTimeIndex).toBe(searchConfig.FOLDERS_CONSTANTS.TEMP_REAL_TIME_INDEX); expect(SearchApi.realTimeIndex).toBe(searchConfig.FOLDERS_CONSTANTS.TEMP_REAL_TIME_INDEX);
expect(SearchApi.batchIndex).toBe(searchConfig.FOLDERS_CONSTANTS.TEMP_BATCH_INDEX_FOLDER); 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'); const getLatestMessageTimestamp = jest.spyOn(SearchApi, 'getLatestMessageTimestamp');
SearchApi.getLatestMessageTimestamp().catch(function (err) { SearchApi.getLatestMessageTimestamp().catch(function (err) {
expect(err).toEqual(new Error('Index folder does not exist.')); 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).toHaveBeenCalled();
expect(getLatestMessageTimestamp).toHaveBeenCalledTimes(3); expect(getLatestMessageTimestamp).toHaveBeenCalledTimes(3);
done(); done();