Refactor getImages function to use dynamic directory path for image validation
All checks were successful
CI / build (push) Successful in 31s
All checks were successful
CI / build (push) Successful in 31s
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user