From 2775eed0779727fb2efc0cf0a1ed47acc21e6137 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Wed, 21 Oct 2020 11:00:19 +0200 Subject: [PATCH] More robust indexify --- indexify.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/indexify.js b/indexify.js index 1c6e7e1..7925e4f 100644 --- a/indexify.js +++ b/indexify.js @@ -4,10 +4,14 @@ const VIDEO_DIR = "videos"; const DESCRIPTION_FILE = "description.json"; const INDEX_FILE = "index.json"; +function isDirectory(path) { + return fs.lstatSync(path).isDirectory(); +} + let info = []; for (let dir of fs.readdirSync(VIDEO_DIR)) { - if (dir === INDEX_FILE) { + if (!isDirectory(path.join(VIDEO_DIR, dir))) { continue; } @@ -16,7 +20,7 @@ for (let dir of fs.readdirSync(VIDEO_DIR)) { description.videos = []; for (let subdir of fs.readdirSync(path.join(VIDEO_DIR, dir))) { - if (subdir === DESCRIPTION_FILE) { + if (!isDirectory(path.join(VIDEO_DIR, dir, subdir))) { continue; }