Work on configs
This commit is contained in:
33
index.js
33
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)) {
|
||||
|
||||
Reference in New Issue
Block a user