Skip to content

Commit

Permalink
catch perm errors by sending blank list for directory
Browse files Browse the repository at this point in the history
  • Loading branch information
thelamer committed Mar 15, 2023
1 parent 2578550 commit c9e5f44
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
28 changes: 16 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,24 @@ io.on('connection', async function (socket) {

// Get file list for directory
async function getFiles(directory) {
let items = await fsw.readdir(directory);
if (items.length > 0) {
let dirs = [];
let files = [];
for await (let item of items) {
let fullPath = directory + '/' + item;
if (fs.lstatSync(fullPath).isDirectory()) {
dirs.push(item);
} else {
files.push(item);
try {
let items = await fsw.readdir(directory);
if (items.length > 0) {
let dirs = [];
let files = [];
for await (let item of items) {
let fullPath = directory + '/' + item;
if (fs.lstatSync(fullPath).isDirectory()) {
dirs.push(item);
} else {
files.push(item);
}
}
send('renderfiles', [dirs, files, directory]);
} else {
send('renderfiles', [[], [], directory]);
}
send('renderfiles', [dirs, files, directory]);
} else {
} catch (error) {
send('renderfiles', [[], [], directory]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kclient",
"version": "0.3.3",
"version": "0.3.4",
"description": "Kclient is a wrapper for KasmVNC to add functionality to a containerized environment",
"main": "index.js",
"dependencies": {
Expand Down

0 comments on commit c9e5f44

Please sign in to comment.