SEARCH-539 & SEARCH-206

- Removed .enc
This commit is contained in:
Keerthi Niranjan 2017-12-19 16:51:02 +05:30
parent 867fe40d72
commit f7b6597c1a
2 changed files with 7 additions and 7 deletions

View File

@ -127,7 +127,7 @@
</div>
<script>
var search = new ssf.Search("12345678910112", "jjjehdnctsjyieoalskcjdhsnahsadndfnusdfsdfsd=", 'v2');
var search = new ssf.Search("12345678910112", "jjjehdnctsjyieoalskcjdhsnahsadndfnusdfsdfsd=");
var searchUtils = new ssf.SearchUtils();
var buttonEl = document.getElementById('search');
var merge = document.getElementById('merge');
@ -231,8 +231,8 @@
merge.addEventListener('click', function () {
search.mergeIndexBatches().then(function () {
search.encryptIndex('jjjehdnctsjyieoalskcjdhsnahsadndfnusdfsdfsd=', 'v2').then(function () {
searchUtils.updateUserConfig(12345678910112, {rotationId:0, version: 'v2'}).then(function (res) {
search.encryptIndex('jjjehdnctsjyieoalskcjdhsnahsadndfnusdfsdfsd=').then(function () {
searchUtils.updateUserConfig(12345678910112, {rotationId:0, version: 1}).then(function (res) {
resultsEl.innerHTML = JSON.stringify(res);
}).catch(function (err) {
resultsEl.innerHTML = JSON.stringify(err);

View File

@ -22,7 +22,7 @@ class Crypto {
this.permanentIndexName = `${searchConfig.FOLDERS_CONSTANTS.PREFIX_NAME}_${userId}_${searchConfig.INDEX_VERSION}`;
this.dump = DUMP_PATH;
this.key = key;
this.encryptedIndex = `${DUMP_PATH}/${this.permanentIndexName}`;
this.encryptedIndex = `${DUMP_PATH}/${this.permanentIndexName}.enc`;
this.dataFolder = searchConfig.FOLDERS_CONSTANTS.INDEX_PATH;
}
@ -52,7 +52,7 @@ class Crypto {
log.send(logLevels.WARN, 'Crypto: Child process stderr while compression, ' + response.stderr);
}
const input = fs.createReadStream(`${this.dump}/${this.permanentIndexName}${searchConfig.TAR_LZ4_EXT}`);
const outputEncryption = fs.createWriteStream(`${this.encryptedIndex}.enc`);
const outputEncryption = fs.createWriteStream(this.encryptedIndex);
let config = {
key: key
};
@ -81,13 +81,13 @@ class Crypto {
decryption() {
return new Promise((resolve, reject) => {
if (!fs.existsSync(`${this.encryptedIndex}.enc`)){
if (!fs.existsSync(this.encryptedIndex)){
log.send(logLevels.ERROR, 'Crypto: Encrypted file not found');
reject();
return;
}
const input = fs.createReadStream(`${this.encryptedIndex}.enc`);
const input = fs.createReadStream(this.encryptedIndex);
const output = fs.createWriteStream(`${this.dump}/decrypted${searchConfig.TAR_LZ4_EXT}`);
let config = {
key: this.key