summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/js/config.js24
-rw-r--r--server/js/paths.js13
2 files changed, 31 insertions, 6 deletions
diff --git a/server/js/config.js b/server/js/config.js
index b1e6836..c21a246 100644
--- a/server/js/config.js
+++ b/server/js/config.js
@@ -18,17 +18,33 @@ function createConfig()
}
};
- fs.writeFileSync(configPath, JSON.stringify(defaultConfig), 'utf-8');
+ try
+ {
+ fs.writeFileSync(configPath, JSON.stringify(defaultConfig), 'utf-8');
+ }
+
+ catch (err)
+ {
+ console.log(err);
+ }
}
function loadConfig(configPath)
{
- if (!fs.existsSync(configPath))
+ try
{
- createConfig(configPath, defaultConfig);
+ if (!fs.existsSync(configPath))
+ {
+ createConfig(configPath, defaultConfig);
+ }
+
+ this.loadedConfig = JSON.parse(fs.readFileSync(configPath));
}
- this.loadedConfig = JSON.parse(fs.readFileSync(configPath));
+ catch (err)
+ {
+ console.log(err);
+ }
}
module.exports = { loadConfig, defaultConfigPath, loadedConfig }; \ No newline at end of file
diff --git a/server/js/paths.js b/server/js/paths.js
index 3bf6824..003d9c0 100644
--- a/server/js/paths.js
+++ b/server/js/paths.js
@@ -6,10 +6,19 @@ const os = require('os');
function ensureFolder(folder)
{
- if (!fs.existsSync(folder))
+ try
{
- fs.mkdirSync(folder, { recursive: true });
+ if (!fs.existsSync(folder))
+ {
+ fs.mkdirSync(folder, { recursive: true });
+ }
}
+
+ catch (err)
+ {
+ console.log(err);
+ }
+
return folder;
}