nvm
This commit is contained in:
parent
8961f585e6
commit
5d5c4a11c9
13
js/main.js
13
js/main.js
|
@ -93,7 +93,14 @@ var bdSettingsStorage = {};
|
|||
bdSettingsStorage.initialize = function() {
|
||||
let fs = require("fs");
|
||||
let data = {};
|
||||
if (fs.existsSync(bdConfig.dataPath + "/bdsettings.json")) data = JSON.parse(fs.readFileSync(bdConfig.dataPath + "/bdsettings.json"));
|
||||
if (fs.existsSync(bdConfig.dataPath + "/bdsettings.json")) {
|
||||
try {
|
||||
data = JSON.parse(fs.readFileSync(bdConfig.dataPath + "/bdsettings.json"));
|
||||
}
|
||||
catch (err) {
|
||||
data = {};
|
||||
}
|
||||
}
|
||||
if (data) bdSettings = data;
|
||||
else bdSettings = {};
|
||||
}
|
||||
|
@ -103,11 +110,11 @@ bdSettingsStorage.get = function(key) {
|
|||
else return null;
|
||||
}
|
||||
|
||||
bdSettingsStorage.set = async function(key, data) {
|
||||
bdSettingsStorage.set = function(key, data) {
|
||||
let fs = require("fs");
|
||||
bdSettings[key] = data;
|
||||
try {
|
||||
await new Promise(resolve => fs.writeFile(bdConfig.dataPath + "/bdsettings.json", JSON.stringify(bdSettings, null, 4), resolve));
|
||||
fs.writeFileSync(bdConfig.dataPath + "/bdsettings.json", JSON.stringify(bdSettings, null, 4));
|
||||
return true;
|
||||
}
|
||||
catch(err) {
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue