From f9c64963ac1e2dc3d5b5db7ab6ecfb5b6385bfa9 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Sun, 20 Aug 2023 20:21:22 +0200 Subject: fixed packages.list() assuming packages dir exists This generally is fine, as the folder is created on startup... IF Northstar is installed! And so, if you start Viper for the first time or Viper as only just extracted/created the R2Northstar folder, then the folder wont exist, but it'll simply assume as such. Now we actually handle this correctly. --- src/modules/packages.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/modules/packages.js b/src/modules/packages.js index f868d16..d6420b9 100644 --- a/src/modules/packages.js +++ b/src/modules/packages.js @@ -59,6 +59,13 @@ packages.split_name = (name) => { } packages.list = (dir = packages.path, no_functions) => { + update_path(); + + if (! fs.existsSync(packages.path) + || dir == "R2Northstar/packages") { + return {}; + } + let files = fs.readdirSync(dir); let package_list = {}; @@ -173,6 +180,15 @@ packages.remove = (author, package_name, version) => { packages.install = async (url, author, package_name, version) => { update_path(); + if (! fs.existsSync(packages.path)) { + console.error( + "Can't install package, packages folder doesn't exist", + "and couldn't be created" + ) + + return false; + } + let name = packages.format_name(author, package_name, version); // removes zip's and folders -- cgit v1.2.3