Refactor getImages function to use dynamic directory path for image validation
All checks were successful
CI / build (push) Successful in 31s

This commit is contained in:
2025-07-23 19:45:51 +00:00
parent 37be318156
commit b2d69dc969

View File

@@ -16,14 +16,16 @@ function getImages() {
const lines = fs.readFileSync(CSV_FILE, "utf-8").split("\n"); const lines = fs.readFileSync(CSV_FILE, "utf-8").split("\n");
if (VERBOSE) console.log(`[pictshare-browse] CSV file line count: ${lines.length}`); if (VERBOSE) console.log(`[pictshare-browse] CSV file line count: ${lines.length}`);
let skipped = 0; let skipped = 0;
const path = require("path");
const csvDir = path.dirname(CSV_FILE);
const images = lines const images = lines
.filter(line => line.includes(";")) .filter(line => line.includes(";"))
.map(line => { .map(line => {
const [hash, filename] = line.split(";"); const [hash, filename] = line.split(";");
const folderPath = `./uploads/${filename.trim()}`; const dirPath = path.join(csvDir, filename.trim());
if (!fs.existsSync(folderPath) || !fs.lstatSync(folderPath).isDirectory()) { if (!fs.existsSync(dirPath) || !fs.lstatSync(dirPath).isDirectory()) {
skipped++; 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 null;
} }
return { return {