Skip to content

Commit

Permalink
fix for invalid folder (#7609)
Browse files Browse the repository at this point in the history
Co-authored-by: PhotoNomad0 <bruce.mclean@unfoldingword.org>
  • Loading branch information
PhotoNomad0 and PhotoNomad0 authored Dec 16, 2024
1 parent 3ccbde3 commit 3ab8d36
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/js/helpers/ResourcesHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1176,14 +1176,18 @@ export function getFoldersInResourceFolder(resourcePath) {
* @return {Array}
*/
export function getFilesInResourcePath(resourcePath, ext=null) {
if (fs.lstatSync(resourcePath).isDirectory()) {
let files = fs.readdirSync(resourcePath).filter(file => {
if (ext) {
return path.extname(file) === ext;
}
return file !== '.DS_Store';
}); // filter out .DS_Store
return files;
try {
if (fs.existsSync(resourcePath)) {
let files = fs.readdirSync(resourcePath).filter(file => {
if (ext) {
return path.extname(file) === ext;
}
return file !== '.DS_Store';
}); // filter out .DS_Store
return files;
}
} catch (e) {
console.warn(`ResourceHelpers.getFilesInResourcePath() - invalid path: ${resourcePath}`,e);
}
return [];
}
Expand Down

0 comments on commit 3ab8d36

Please sign in to comment.