From b2d69dc9695d0dd1c86d336864f597da16798348 Mon Sep 17 00:00:00 2001 From: Ryan Hamilton Date: Wed, 23 Jul 2025 19:45:51 +0000 Subject: [PATCH] Refactor getImages function to use dynamic directory path for image validation --- src/getImages.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/getImages.js b/src/getImages.js index 3a0f254..def0ee8 100644 --- a/src/getImages.js +++ b/src/getImages.js @@ -16,14 +16,16 @@ function getImages() { const lines = fs.readFileSync(CSV_FILE, "utf-8").split("\n"); if (VERBOSE) console.log(`[pictshare-browse] CSV file line count: ${lines.length}`); let skipped = 0; + const path = require("path"); + const csvDir = path.dirname(CSV_FILE); const images = lines .filter(line => line.includes(";")) .map(line => { const [hash, filename] = line.split(";"); - const folderPath = `./uploads/${filename.trim()}`; - if (!fs.existsSync(folderPath) || !fs.lstatSync(folderPath).isDirectory()) { + const dirPath = path.join(csvDir, filename.trim()); + if (!fs.existsSync(dirPath) || !fs.lstatSync(dirPath).isDirectory()) { skipped++; - if (VERBOSE) console.warn(`[pictshare-browse] Skipping: ${filename.trim()} (missing folder: ${folderPath})`); + if (VERBOSE) console.warn(`[pictshare-browse] Skipping: ${filename.trim()} (missing directory: ${dirPath})`); return null; } return {