Working on rewrite version 3. Focus on caching for now.
This commit is contained in:
34
index.js
34
index.js
@@ -94,16 +94,19 @@ app.on('activate', () => {
|
||||
})
|
||||
|
||||
|
||||
ipcMain.on('download_file', (event, api_base_url, api_endpoint, api_temporary_token, save_path) => {
|
||||
console.log('ipcMain on download_file: api_base_url='+api_base_url+' | api_temporary_token='+api_temporary_token);
|
||||
console.log(api_temporary_token);
|
||||
// ipcMain.on('download_file', (event, api_base_url, api_endpoint, api_temporary_token, save_path) => {
|
||||
ipcMain.on('download_file', (event, api_base_url, api_endpoint, save_path) => {
|
||||
console.log('*** call IPC download_file() ***');
|
||||
// console.log('ipcMain on download_file: api_base_url='+api_base_url+' | api_temporary_token='+api_temporary_token);
|
||||
console.log('ipcMain on download_file: api_base_url='+api_base_url);
|
||||
// console.log(api_temporary_token);
|
||||
console.log('ipcMain download and save file: '+api_endpoint+' -> '+save_path);
|
||||
|
||||
axios.defaults.baseURL = api_base_url;
|
||||
axios.defaults.headers.common['Access-Control-Allow-Origin'] = access_control_allow_origin;
|
||||
axios.defaults.headers.common['Access-Control-Allow-Origin'] = '*'; // app_config.access_control_allow_origin;
|
||||
axios.defaults.headers.common['content-type'] = 'application/json';
|
||||
axios.defaults.headers.common['x-aether-api-key'] = api_secret_key;
|
||||
axios.defaults.headers.common['x-account-id'] = account_id;
|
||||
axios.defaults.headers.common['x-aether-api-key'] = 'dFP6J9DVj9hUgIMn-fNIqg'; // api_secret_key;
|
||||
axios.defaults.headers.common['x-account-id'] = '_XY7DXtc9MY'; // account_id;
|
||||
|
||||
const url = api_endpoint;
|
||||
|
||||
@@ -118,12 +121,19 @@ ipcMain.on('download_file', (event, api_base_url, api_endpoint, api_temporary_to
|
||||
|
||||
|
||||
|
||||
ipcMain.on('open_local_file', (event, file_path, filename) => {
|
||||
console.log('ipcMain open local file: '+file_path+' -> '+filename);
|
||||
// ipcMain.on('open_local_file', (event, file_path, filename) => {
|
||||
// ipcMain.on('open_local_file', ({host_file_cache_path, hash, filename}) => {
|
||||
ipcMain.on('open_local_file', (event, host_file_cache_path, hash, filename) => {
|
||||
console.log(host_file_cache_path);
|
||||
console.log('ipcMain open local file: '+host_file_cache_path+' -> '+filename);
|
||||
|
||||
cache_file_path = path.join(process.cwd(), file_path);
|
||||
let cache_file_path = path.join(process.cwd(), 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_file_path = path.join(process.cwd(), 'temp/', filename);
|
||||
console.log(open_file_path);
|
||||
|
||||
@@ -136,11 +146,11 @@ ipcMain.on('open_local_file', (event, file_path, filename) => {
|
||||
console.log('File copy already exists: '+open_file_path);
|
||||
} else {
|
||||
//console.log('Creating file link: '+open_file_path);
|
||||
//fs.linkSync(cache_file_path, open_file_path);
|
||||
//fs.linkSync(full_cache_file_path, open_file_path);
|
||||
console.log('Copying file to temp: '+open_file_path);
|
||||
fs.copyFileSync(cache_file_path, open_file_path);
|
||||
fs.copyFileSync(full_cache_file_path, open_file_path);
|
||||
}
|
||||
|
||||
shell.openItem(open_file_path);
|
||||
shell.openPath(open_file_path);
|
||||
//fs.open(open_file_path);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user