diff --git a/index.js b/index.js index a15def8..5f93f6f 100644 --- a/index.js +++ b/index.js @@ -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]); } } diff --git a/package.json b/package.json index f0a7b81..e4aa681 100644 --- a/package.json +++ b/package.json @@ -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": {