Working on rewrite version 3. Focus on caching for now.
This commit is contained in:
@@ -69,6 +69,28 @@ exports.load_config = function () {
|
||||
}
|
||||
|
||||
|
||||
exports.check_file_cache_v3 = async function (host_file_cache_path, event_file_id, hash) {
|
||||
console.log('**** *** ** * FUNCTION: check_file_cache_v3 * ** *** ****');
|
||||
console.log('Checking the local file cache against the remote server.');
|
||||
|
||||
event_file_id; // NOTE: This is the event_file.id_random or event_file.event_file_id_random
|
||||
let hash_filename = hash+'.file';
|
||||
|
||||
let save_path = path.join(host_file_cache_path, hash_filename);
|
||||
console.log(save_path);
|
||||
|
||||
if (fs.existsSync(save_path)) {
|
||||
console.log('Local file already exists: '+save_path);
|
||||
} else {
|
||||
console.log('File not found locally. Downloading file: '+save_path);
|
||||
let endpoint = `/event/file/${event_file_id}/download`;
|
||||
ipcRenderer.send('download_file', api_base_url, endpoint, save_path); // Must download file using main node.js thread.
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
exports.check_file_cache = async function () {
|
||||
console.log('**** *** ** * FUNCTION: check_file_cache * ** *** ****');
|
||||
console.log('Checking the local file cache against the remote server.');
|
||||
|
||||
Reference in New Issue
Block a user