Testing for windows

This commit is contained in:
Keerthi Niranjan 2017-07-27 10:48:11 +05:30 committed by Keerthi Niranjan
parent 4f0236b3ff
commit c76397f601
4 changed files with 37 additions and 10 deletions

View File

@ -10,21 +10,24 @@
padding: 5px;
text-align: center;
}
.hidden {
display: none;
}
input {
padding: 5px;
margin: 2px 0;
border: 1px solid #ccc;
}
label {
padding-right: 10px;
}
button {
padding: 10px;
background-color: rgba(0,64,98,0.7);
background-color: rgba(0, 64, 98, 0.7);
color: white;
}
</style>
@ -85,7 +88,7 @@
</div>
</body>
<script>
var search = new ssf.Search("akon");
var search = new ssf.Search("testUser1");
var buttonEl = document.getElementById('search');
var merge = document.getElementById('merge');
var buttonIndex = document.getElementById('index')
@ -145,7 +148,6 @@
tr.appendChild(t3);
table.appendChild(tr);
});
/*search.freeResults(JSON.stringify(out));*/
});
});

View File

@ -3,6 +3,13 @@
const fs = require('fs');
const randomString = require('randomstring');
const electron = require('electron');
const app = electron.app;
const path = require('path');
const isDevEnv = require('../utils/misc.js').isDevEnv;
const isMac = require('../utils/misc.js').isMac;
const libSymphonySearch = require('./searchLibrary');
const TEMP_BATCH_INDEX_FOLDER = './data/temp_batch_indexes';
const TEMP_REALTIME_INDEX = './data/temp_realtime_index';
@ -17,11 +24,12 @@ const SORT_BY_SCORE = 0;
const BATCH_RANDOM_INDEX_PATH_LENGTH = 20;
let execPath = path.dirname(app.getPath('exe'));
class Search {
constructor(userId) {
this.isInitialized = false;
this.messageData = [];
this.userId = userId;
this.startIndexingFromDate = (new Date().getTime() - SEARCH_PERIOD_SUBTRACTOR).toString();
this.indexFolderName = INDEX_PREFIX + '_' + userId + '_' + INDEX_VERSION;
@ -76,15 +84,18 @@ class Search {
});
}
/*eslint-disable class-methods-use-this */
readJson() {
return new Promise((resolve, reject) => {
var files = fs.readdirSync('./msgsjson');
this.messageData = [];
let dirPath = path.join(execPath, isMac ? '..' : '', 'Resources/msgsjson');
let messageFolderPath = isDevEnv ? './msgsjson/' : dirPath;
let files = fs.readdirSync(messageFolderPath);
let messageData = [];
files.forEach(function (file) {
let data = fs.readFileSync('./msgsjson/' + file, "utf8");
let data = fs.readFileSync(messageFolderPath + file, "utf8");
if (data) {
this.messageData.push(JSON.parse(data));
resolve(this.messageData);
messageData.push(JSON.parse(data));
resolve(messageData);
} else {
reject("err on reading files")
}
@ -133,6 +144,9 @@ class Search {
let returnedResult = libSymphonySearch.symSESearch(this.indexFolderName, TEMP_REALTIME_INDEX, q, sd_str, ed_str, offset, limit, sortOrder);
let ret = JSON.parse(returnedResult);
resolve(ret);
if (ret.messages.length > 0) {
libSymphonySearch.symSEFreeResultAsync(returnedResult);
}
});
}

View File

@ -3,10 +3,20 @@
const ffi = require('ffi');
const ref = require('ref');
const electron = require('electron');
const app = electron.app;
const path = require('path');
const isDevEnv = require('../utils/misc.js').isDevEnv;
const isMac = require('../utils/misc.js').isMac;
var symLucyIndexer = ref.types.void;
var symLucyIndexerPtr = ref.refType(symLucyIndexer);
let execPath = path.dirname(app.getPath('exe'));
let libraryPath = isMac ? 'Resources/libsymphonysearch' : 'Resources/libsymphonysearchwin64';
let fullPath = path.join(execPath, isMac ? '..' : '', libraryPath);
let libPath = isDevEnv ? 'libsymphonysearch.dylib' : fullPath;
var libSymphonySearch = ffi.Library('libsymphonysearch', {
var libSymphonySearch = ffi.Library(libPath, {
//init
'symSE_init': ['void', []],
'symSE_remove_folder': ['int', ['string']],

View File

@ -33,6 +33,7 @@
"!installer/*",
"!tests/*"
],
"extraResources": ["msgsjson", "libsymphonysearch.dylib", "libsymphonysearchwin64.dll"],
"extraFiles": "config/Symphony.config",
"appId": "symphony-electron-desktop",
"mac": {