From 1dd0da67333c50ee1a2b434ca15ecbfec603515e Mon Sep 17 00:00:00 2001 From: FunnyGuy9796 Date: Sat, 10 Aug 2024 22:18:42 +0000 Subject: [PATCH] minor fixes --- app.js | 26 ++++++++++++++++++-------- filo_modules/fs.js | 8 ++++++-- filo_services/taskbar/index.js | 3 +++ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/app.js b/app.js index 8eb5dba..1ddfd14 100644 --- a/app.js +++ b/app.js @@ -129,13 +129,19 @@ async function stopService(serviceId) { const resolvedPath = require.resolve(path.join(servicesPath, serviceId, "main.js")); if (require.cache[resolvedPath]) { - const result = await require(resolvedPath).stop(); + try { + const serviceModule = require(resolvedPath); - if (result) { - memory.removeData("services", "id = '" + serviceId + "'"); - delete require.cache[resolvedPath]; + const result = await serviceModule.stop(); - console.log(chalk.cyan.bold("[FILO/SERVICES]") + " -> Stopped system service | Service ID: " + serviceId); + if (result) { + memory.removeData("services", "id = '" + serviceId + "'"); + delete require.cache[resolvedPath]; + + console.log(chalk.cyan.bold("[FILO/SERVICES]") + " -> Stopped system service | Service ID: " + serviceId); + } + } catch (error) { + console.log(chalk.cyan.bold("[FILO/SERVICES") + "::" + chalk.red.bold("ERROR") + chalk.cyan.bold("]") + " -> " + error); } } } @@ -568,18 +574,22 @@ async function boot() { process.exit(1); } } catch (error) { - console.log(chalk.cyan.bold("[FILO/MODULES") + "::" + chalk.red.bold("ERROR") + chalk.cyan.bold("]") + " -> " + error); + console.log(chalk.cyan.bold("[FILO") + "::" + chalk.red.bold("ERROR") + chalk.cyan.bold("]") + " -> " + error); cleanup(); process.exit(1); } } -function cleanup() { +async function cleanup() { console.log(chalk.cyan.bold("[FILO]") + " -> Cleaning up before shutting down.."); - fs.saveFs((status, message) => { + fs.saveFs((status, message, error) => { console.log(chalk.cyan.bold("[FILO/MODULES]") + " -> Saving filesystem.. " + message); + + if (!status) { + console.log(chalk.cyan.bold("[FILO/MODULES") + "::" + chalk.red.bold("ERROR") + chalk.cyan.bold("]") + " -> " + error); + } }); memory.db.close(); diff --git a/filo_modules/fs.js b/filo_modules/fs.js index 88779f7..705f3a1 100644 --- a/filo_modules/fs.js +++ b/filo_modules/fs.js @@ -220,9 +220,13 @@ function checkFile(path) { function saveFs(callback) { const snapshot = vol.toJSON(); - realFs.writeFileSync(snapshotFile, JSON.stringify(snapshot, null, 2)); + try { + realFs.writeFileSync(snapshotFile, JSON.stringify(snapshot, null, 2)); - callback(true, "[" + chalk.green.bold("DONE") + "]"); + callback(true, "[" + chalk.green.bold("DONE") + "]"); + } catch (error) { + callback(false, "[" + chalk.red.bold("FAILED") + "]", error); + } } function checkFs(callback) { diff --git a/filo_services/taskbar/index.js b/filo_services/taskbar/index.js index 3c3b3dc..bec05d6 100644 --- a/filo_services/taskbar/index.js +++ b/filo_services/taskbar/index.js @@ -24,6 +24,9 @@ function init() { } function stop() { + const taskbarNode = memory.readNode("taskbar"); + console.log(`taskbarNode: ${taskbarNode}`); + memory.deleteNode("taskbar"); return true;