More robust indexify

This commit is contained in:
Thomas Forgione 2020-10-21 11:00:19 +02:00
parent 948df5da9a
commit 2775eed077
1 changed files with 6 additions and 2 deletions

View File

@ -4,10 +4,14 @@ const VIDEO_DIR = "videos";
const DESCRIPTION_FILE = "description.json"; const DESCRIPTION_FILE = "description.json";
const INDEX_FILE = "index.json"; const INDEX_FILE = "index.json";
function isDirectory(path) {
return fs.lstatSync(path).isDirectory();
}
let info = []; let info = [];
for (let dir of fs.readdirSync(VIDEO_DIR)) { for (let dir of fs.readdirSync(VIDEO_DIR)) {
if (dir === INDEX_FILE) { if (!isDirectory(path.join(VIDEO_DIR, dir))) {
continue; continue;
} }
@ -16,7 +20,7 @@ for (let dir of fs.readdirSync(VIDEO_DIR)) {
description.videos = []; description.videos = [];
for (let subdir of fs.readdirSync(path.join(VIDEO_DIR, dir))) { for (let subdir of fs.readdirSync(path.join(VIDEO_DIR, dir))) {
if (subdir === DESCRIPTION_FILE) { if (!isDirectory(path.join(VIDEO_DIR, dir, subdir))) {
continue; continue;
} }