From a177bb18c4da773581146d5db1bf8705e740c5d8 Mon Sep 17 00:00:00 2001 From: Hoang Nguyen <50922013+catmandx@users.noreply.github.com> Date: Fri, 10 Feb 2023 14:09:50 +0700 Subject: [PATCH 1/3] Update api.js Fix error when using local storage, the app does not append the SCREENSHOTS_DIR variable when reading screenshot file but does so when writing. --- api.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api.js b/api.js index 0a3a405..3b59509 100644 --- a/api.js +++ b/api.js @@ -216,7 +216,7 @@ async function set_up_api_server(app) { return res.sendStatus(404); } - const gz_image_path = `${screenshot_filename}.gz`; + var gz_image_path = `${screenshot_filename}.gz`; if (process.env.USE_CLOUD_STORAGE == "true"){ const storage = new Storage(); @@ -237,6 +237,7 @@ async function set_up_api_server(app) { res.status(404).send(`Error retrieving image from GCS`); } }else{ + gz_image_path = `${SCREENSHOTS_DIR}/${gz_image_path}`; const image_exists = await check_file_exists(gz_image_path); if(!image_exists) { From 260a3af324a283fd4b5d84fa048a0490f2b30994 Mon Sep 17 00:00:00 2001 From: Hoang Nguyen <50922013+catmandx@users.noreply.github.com> Date: Fri, 10 Feb 2023 14:13:40 +0700 Subject: [PATCH 2/3] Update docker-compose.yml Merge 2 "volumes" tag due to Docker disregarding the former. --- docker-compose.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 6866c44..47e9d9c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,11 +10,10 @@ services: volumes: # Directory where payload fire images are stored. - ./payload-fire-images:/app/payload-fire-images + - ~/.config/gcloud/application_default_credentials.json:/gcloud.json depends_on: postgresdb: condition: service_healthy - volumes: - - ~/.config/gcloud/application_default_credentials.json:/gcloud.json postgresdb: image: postgres restart: always From 2bd4509511523855c0f924e3a2054fe698050eb2 Mon Sep 17 00:00:00 2001 From: Hoang Nguyen <50922013+catmandx@users.noreply.github.com> Date: Fri, 10 Feb 2023 15:52:59 +0700 Subject: [PATCH 3/3] Update api.js Fixing an incomplete fix regarding local image storage file path --- api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api.js b/api.js index 3b59509..0ec267e 100644 --- a/api.js +++ b/api.js @@ -405,7 +405,7 @@ async function set_up_api_server(app) { })); }else{ await Promise.all(screenshots_to_delete.map(screenshot_path => { - return asyncfs.unlink(screenshot_path); + return asyncfs.unlink(`${SCREENSHOTS_DIR}/${screenshot_path}`); })); } const payload_fires = await PayloadFireResults.destroy({