diff --git a/app/index.html b/app/index.html
index 2d9fb64..d59e105 100644
--- a/app/index.html
+++ b/app/index.html
@@ -27,7 +27,7 @@
-
+
@@ -76,10 +76,10 @@
const page_for = { 'event': event_id, 'event_device': event_device_id, 'event_location': event_location_id }; // Simple key value like object
console.log(page_for);
- const host_file_cache_path = 'file_cache'; // app_config.host_file_cache_path; // 'file_cache/'
- console.log(host_file_cache_path);
- const host_file_temp_path = 'temp' // app_config.host_file_temp_path; // 'temp/'
- console.log(host_file_temp_path);
+ const host_file_cache_path = app_config.host_file_cache_path; // 'file_cache/'
+ // console.log(host_file_cache_path);
+ const host_file_temp_path = app_config.host_file_temp_path; // 'temp/'
+ // console.log(host_file_temp_path);
let idb_name = app_config.idb_name;
diff --git a/app/js/aether_native_app_v3.js b/app/js/aether_native_app_v3.js
index 067fb00..6f5fbdb 100644
--- a/app/js/aether_native_app_v3.js
+++ b/app/js/aether_native_app_v3.js
@@ -4,17 +4,23 @@ const path = require('path');
const fs = require('fs');
const { ipcRenderer } = require('electron');
+let home_directory = require('os').homedir();
+console.log('Home: '+home_directory);
+
+let tmp_directory = require('os').tmpdir();
+console.log('Temporary: '+tmp_directory);
+
let config = null;
exports.load_config = function () {
console.log('*** Electron framework: load_config() ***');
console.log('CWD: '+process.cwd());
- let home_directory = require('os').homedir();
- console.log('Home: '+home_directory);
+ // let home_directory = require('os').homedir();
+ // console.log('Home: '+home_directory);
- let tmp_directory = require('os').tmpdir();
- console.log('Temporary: '+tmp_directory);
+ // let tmp_directory = require('os').tmpdir();
+ // console.log('Temporary: '+tmp_directory);
// let config = null;
let config_directory = null;
@@ -71,6 +77,14 @@ exports.load_config = function () {
//close();
}
+ config.host_file_cache_path = config.host_file_cache_path.replace('[home]', home_directory);
+ config.host_file_cache_path = config.host_file_cache_path.replace('[tmp]', tmp_directory);
+ console.log(config.host_file_cache_path);
+
+ config.host_file_temp_path = config.host_file_temp_path.replace('[home]', home_directory);
+ config.host_file_temp_path = config.host_file_temp_path.replace('[tmp]', tmp_directory);
+ console.log(config.host_file_temp_path);
+
let import_config_to_ipc_result = ipcRenderer.invoke('import_config', config).then((result) => {
console.log('IPC import config finished');
console.log(result);
diff --git a/config.json b/config.json
index 60dc8b5..03d0bb6 100644
--- a/config.json
+++ b/config.json
@@ -24,9 +24,9 @@
"idb_event_presenter_check_period": 60000,
"idb_event_file_check_period": 30000,
- "host_file_cache_path": "file_cache",
+ "host_file_cache_path": "[home]/tmp/OSIT/file_cache",
"host_file_cache_check_period": 30000,
- "host_file_temp_path": "temp",
+ "host_file_temp_path": "[home]/tmp/OSIT/temp",
"main_loop_interval": 2000,
"api_token_loop_interval": 1000,
diff --git a/index.js b/index.js
index bac30d4..fd917f5 100644
--- a/index.js
+++ b/index.js
@@ -11,7 +11,15 @@ const process = require('process');
//const url = require('url');
// const usb = require('usb') // Compiled with an old version of Node.js
+let home_directory = require('os').homedir();
+console.log('Home: '+home_directory);
+
+let tmp_directory = require('os').tmpdir();
+console.log('Temporary: '+tmp_directory);
+
let config = null;
+let host_file_cache_path = null;
+let host_file_temp_path = null;
console.log(os.type());
console.log(process.getSystemVersion());
@@ -109,6 +117,23 @@ ipcMain.handle('import_config', async (event, config_data) => {
config = config_data;
+ host_file_cache_path = config.host_file_cache_path;
+ host_file_temp_path = config.host_file_temp_path;
+
+ if (fs.existsSync(host_file_cache_path)) {
+ console.log('Host file cache path exists: '+host_file_cache_path);
+ } else {
+ fs.mkdirSync(host_file_cache_path);
+ console.log('Host file cache path created: '+host_file_cache_path);
+ }
+
+ if (fs.existsSync(host_file_temp_path)) {
+ console.log('Host file temp path exists: '+host_file_temp_path);
+ } else {
+ fs.mkdirSync(host_file_temp_path);
+ console.log('Host file temp path created: '+host_file_temp_path);
+ }
+
return true;
});
@@ -204,14 +229,18 @@ ipcMain.handle('open_hash_file_to_temp', async (event, host_file_cache_path, has
console.log('ipcMain on open_hash_file_to_temp');
console.log(`ipcMain open hash file from temp directory: ${host_file_cache_path} -> ${host_file_temp_path}/${filename}`);
- let cache_file_path = path.join(process.cwd(), host_file_cache_path);
+ // NOTE: This may be needed later? Uncomment if paths are relative to working directory.
+ // let cache_file_path = path.join(process.cwd(), host_file_cache_path);
+ let cache_file_path = host_file_cache_path;
console.log(cache_file_path);
let hash_filename = hash+'.file';
let full_cache_file_path = path.join(cache_file_path, hash_filename);
console.log(full_cache_file_path);
- open_temp_file_path = path.join(process.cwd(), host_file_temp_path, filename); // 'temp/'
+ // NOTE: This may be needed later? Uncomment if paths are relative to working directory.
+ // open_temp_file_path = path.join(process.cwd(), host_file_temp_path, filename); // 'temp/'
+ open_temp_file_path = path.join(host_file_temp_path, filename); // 'temp/'
console.log(open_temp_file_path);
if (fs.existsSync(open_temp_file_path)) {