Updated to use individual storage files for plugins
This commit is contained in:
parent
5784e45e87
commit
b7851955b2
|
@ -40,19 +40,21 @@ function initStorage() {
|
||||||
} else {
|
} else {
|
||||||
bdStorage.data = JSON.parse(_fs.readFileSync(_cfg.dataPath + "/bdStorage.json"));
|
bdStorage.data = JSON.parse(_fs.readFileSync(_cfg.dataPath + "/bdStorage.json"));
|
||||||
}
|
}
|
||||||
if(!_fs.existsSync(_cfg.dataPath + "/bdPluginStorage.json")) {
|
|
||||||
bdPluginStorage.data = bdPluginStorage.defaults.data;
|
|
||||||
_fs.writeFileSync(_cfg.dataPath + "/bdPluginStorage.json", JSON.stringify(bdPluginStorage, null, 4));
|
|
||||||
} else {
|
|
||||||
bdPluginStorage.data = JSON.parse(_fs.readFileSync(_cfg.dataPath + "/bdPluginStorage.json"));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
bdStorage.get = function(i, m, pn) {
|
bdStorage.get = function(i, m, pn) {
|
||||||
if(m) return bdStorage.data[i] || "";
|
if(m) return bdStorage.data[i] || "";
|
||||||
if(bdPluginStorage.data[pn] === undefined) bdPluginStorage.data[pn] = {};
|
|
||||||
return bdPluginStorage.data[pn][i] || "";
|
if(bdPluginStorage[pn] !== undefined) {
|
||||||
|
return bdPluginStorage[pn][i] || undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_fs.existsSync(_cfg.dataPath + "/plugins/" + pn + ".config.json")) {
|
||||||
|
bdPluginStorage[pn] = JSON.parse(_fs.readFileSync(_cfg.dataPath + "/plugins/" + pn + ".config.json"));
|
||||||
|
return bdPluginStorage[pn][i] || undefined;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bdStorage.set = function(i, v, m, pn) {
|
bdStorage.set = function(i, v, m, pn) {
|
||||||
|
@ -60,9 +62,9 @@ bdStorage.set = function(i, v, m, pn) {
|
||||||
bdStorage.data[i] = v;
|
bdStorage.data[i] = v;
|
||||||
_fs.writeFileSync(_cfg.dataPath + "/bdstorage.json", JSON.stringify(bdStorage.data, null, 4));
|
_fs.writeFileSync(_cfg.dataPath + "/bdstorage.json", JSON.stringify(bdStorage.data, null, 4));
|
||||||
} else {
|
} else {
|
||||||
if(bdPluginStorage.data[pn] === undefined) bdPluginStorage.data[pn] = {};
|
if(bdPluginStorage[pn] === undefined) bdPluginStorage[pn] = {};
|
||||||
bdPluginStorage.data[pn][i] = v;
|
bdPluginStorage[pn][i] = v;
|
||||||
_fs.writeFileSync(_cfg.dataPath + "/bdPluginStorage.json", JSON.stringify(bdPluginStorage.data, null, 4));
|
_fs.writeFileSync(_cfg.dataPath + "/plugins/" + pn + ".config.json", JSON.stringify(bdPluginStorage[pn], null, 4));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue