More work on major rewrite version 3. Focus on caching and opening after download.

This commit is contained in:
Scott Idem
2022-03-09 19:05:08 -05:00
parent c0f3f7a8ca
commit f0bf184a4a
2 changed files with 45 additions and 36 deletions

View File

@@ -81,7 +81,7 @@ exports.check_hash_file_cache = async function ({host_file_cache_path, hash}) {
let hash_filename = `${hash}.file`;
let hash_file_cache_path = path.join(host_file_cache_path, hash_filename);
console.log(hash_file_cache_path);
// console.log(hash_file_cache_path);
if (fs.existsSync(hash_file_cache_path)) {
console.log(`Hashed file cache already exists: ${hash_file_cache_path}`);
@@ -102,11 +102,11 @@ exports.download_hash_file_to_cache = async function ({host_file_cache_path, eve
let hash_filename = `${hash}.file`;
let hash_file_cache_path = path.join(host_file_cache_path, hash_filename);
console.log(hash_file_cache_path);
// console.log(hash_file_cache_path);
let download_file_result = await ipcRenderer.invoke('download_file', api_base_url, endpoint, hash_file_cache_path).then((result) => {
console.log('IPC download file process finished');
console.log(result);
// console.log(result);
return true;
});
@@ -128,21 +128,30 @@ exports.open_hash_file_to_temp = async function ({host_file_cache_path, hash, ho
console.log('Open cached hash file after copying to temp directory');
console.log(`Host File Cache Path: ${host_file_cache_path}; Hash: ${hash}; Host File Temp Path: ${host_file_temp_path}; Filename: ${filename}`);
ipcRenderer.invoke('open_hash_file_to_temp', host_file_cache_path, hash, host_file_temp_path, filename).then((result) => {
let open_hash_file_to_temp_result = await ipcRenderer.invoke('open_hash_file_to_temp', host_file_cache_path, hash, host_file_temp_path, filename).then((result) => {
console.log('IPC open hash file to temp finished');
console.log(result);
return false;
return true;
})
// let result = await ipcRenderer.send('open_local_file', host_file_cache_path, hash, host_file_temp_path, filename);
// console.log(result);
// return true;
console.log(open_hash_file_to_temp_result);
console.log('End: open_hash_file_to_temp()');
if (open_hash_file_to_temp_result) {
console.log('File opened successfully');
return true;
} else {
console.log('File was not opened successfully');
return false;
}
}
// Check local file cache and download from server if needed.
// Updated 2022-03-09
// exports.check_file_cache = async function ({host_file_cache_path, event_file_id, hash}) {