summaryrefslogtreecommitdiffstats
path: root/server/lib
diff options
context:
space:
mode:
authorJannik Schönartz2020-08-31 19:46:33 +0200
committerJannik Schönartz2020-08-31 19:46:33 +0200
commit6f93a4a8c5accb4ecb2e66e1cd19ef4e586a8a4a (patch)
tree10aac4bf06182b9f6c5b71558398984b480a9766 /server/lib
parentnpm install needed [ipxe builder] Rework to link directorys instead of single... (diff)
downloadbas-6f93a4a8c5accb4ecb2e66e1cd19ef4e586a8a4a.tar.gz
bas-6f93a4a8c5accb4ecb2e66e1cd19ef4e586a8a4a.tar.xz
bas-6f93a4a8c5accb4ecb2e66e1cd19ef4e586a8a4a.zip
[ipxe builder] Add try-catch when reading the builds directory
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/shell.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/server/lib/shell.js b/server/lib/shell.js
index 29986de..4f315e4 100644
--- a/server/lib/shell.js
+++ b/server/lib/shell.js
@@ -122,13 +122,17 @@ module.exports = {
readdirRecursive: function (buildsPath) {
let structure = []
- const directory = fs.readdirSync(buildsPath)
- for (let obj of directory) {
- if (!fs.lstatSync(path.join(buildsPath, obj)).isDirectory()) {
- structure.push({ name: obj, type: 'file' })
- } else {
- structure.push({ name: obj, type: 'directory', children: this.readdirRecursive(path.join(buildsPath, obj)) })
+ try {
+ const directory = fs.readdirSync(buildsPath)
+ for (let obj of directory) {
+ if (!fs.lstatSync(path.join(buildsPath, obj)).isDirectory()) {
+ structure.push({ name: obj, type: 'file' })
+ } else {
+ structure.push({ name: obj, type: 'directory', children: this.readdirRecursive(path.join(buildsPath, obj)) })
+ }
}
+ } catch (error) {
+ return []
}
return structure
},