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

View File

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

View File

@ -3,10 +3,20 @@
const ffi = require('ffi'); const ffi = require('ffi');
const ref = require('ref'); 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 symLucyIndexer = ref.types.void;
var symLucyIndexerPtr = ref.refType(symLucyIndexer); 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 //init
'symSE_init': ['void', []], 'symSE_init': ['void', []],
'symSE_remove_folder': ['int', ['string']], 'symSE_remove_folder': ['int', ['string']],

View File

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