Skip to content

Commit c9e5f44

Browse files
committed
catch perm errors by sending blank list for directory
1 parent 2578550 commit c9e5f44

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

index.js

+16-12
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,24 @@ io.on('connection', async function (socket) {
5959

6060
// Get file list for directory
6161
async function getFiles(directory) {
62-
let items = await fsw.readdir(directory);
63-
if (items.length > 0) {
64-
let dirs = [];
65-
let files = [];
66-
for await (let item of items) {
67-
let fullPath = directory + '/' + item;
68-
if (fs.lstatSync(fullPath).isDirectory()) {
69-
dirs.push(item);
70-
} else {
71-
files.push(item);
62+
try {
63+
let items = await fsw.readdir(directory);
64+
if (items.length > 0) {
65+
let dirs = [];
66+
let files = [];
67+
for await (let item of items) {
68+
let fullPath = directory + '/' + item;
69+
if (fs.lstatSync(fullPath).isDirectory()) {
70+
dirs.push(item);
71+
} else {
72+
files.push(item);
73+
}
7274
}
75+
send('renderfiles', [dirs, files, directory]);
76+
} else {
77+
send('renderfiles', [[], [], directory]);
7378
}
74-
send('renderfiles', [dirs, files, directory]);
75-
} else {
79+
} catch (error) {
7680
send('renderfiles', [[], [], directory]);
7781
}
7882
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kclient",
3-
"version": "0.3.3",
3+
"version": "0.3.4",
44
"description": "Kclient is a wrapper for KasmVNC to add functionality to a containerized environment",
55
"main": "index.js",
66
"dependencies": {

0 commit comments

Comments
 (0)