Refactor video directory handling

main
Filip Borum Poulsen 2 years ago
parent af1e8c780c
commit ecd6cef529

@ -42,19 +42,24 @@ app.get('/videos', (req, res) => {
const list = [];
for (const dir of videoDirs) {
if (!fs.existsSync(dir)) {
continue;
}
fs.readdirSync(dir, { recursive: true }).forEach(fileName => {
if (!fileEndings.includes(path.extname(fileName))) {
return;
try {
if (!fs.existsSync(dir)) {
continue;
}
const file = {
name: fileName,
path: path.resolve(dir, fileName)
};
list.push(file);
});
fs.readdirSync(dir, { recursive: true }).forEach(fileName => {
if (!fileEndings.includes(path.extname(fileName))) {
return;
}
const file = {
name: fileName,
path: path.resolve(dir, fileName)
};
list.push(file);
});
}
catch (error) {
console.error(error);
}
}
res.json(list);

Loading…
Cancel
Save