Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 24531cb1 authored by Rob Swindell's avatar Rob Swindell 💬

Resilience around tickit.ini and freqit.ini file open operations.

Throw exceptions rather than just loggin an "Unable to open" error
(easier tracking fo the soruce of the error). Log the description and
errno value associated with the file open failure.

Create the .ini files if they don't already exist (rather than crashing
out with an error).

Replace the deprecated 'e' file open mode flag with 'x'.
parent 9d68ca3b
Pipeline #612 passed with stage
in 10 minutes and 48 seconds
......@@ -65,8 +65,8 @@ function TickITCfg() {
}
}
if (!tcfg.open("r"))
throw new Error("Unable to open '"+tcfg.name+"'");
if (!tcfg.open(tcfg.exists ? "r" : "w+"))
throw new Error(tcfg.error + " (" + strerror(tcfg.error) + ") opening '" + tcfg.name + "'");
this.gcfg = tcfg.iniGetObject();
lcprops(this.gcfg);
if (this.gcfg.handler !== undefined) {
......@@ -147,9 +147,8 @@ TickITCfg.prototype.get_next_tic_filename = function()
val = f.readBin();
}
else {
if (!f.open("web+")) {
log(LOG_ERROR, "Unable to open file "+f.name+"!");
return undefined;
if (!f.open("wxb+")) {
throw new Error(f.error + " (" + strerror(f.error) + ") opening '" + f.name + "'");
}
val = -1;
}
......@@ -233,7 +232,7 @@ TickITCfg.prototype.save = function()
}
if (!tcfg.open(tcfg.exists ? 'r+':'w+'))
return "Unable to open '"+tcfg.name+"'";
throw new Error(tcfg.error + " (" + strerror(tcfg.error) + ") opening '" + tcfg.name + "'");
writesect(null, this.gcfg);
sects = tcfg.iniGetSections().map(function(v){return v.toLowerCase();});
......@@ -269,9 +268,8 @@ function FREQITCfg()
var key;
var sects;
if (!f.open('r')) {
log(LOG_ERROR, "Unable to open '"+f.name+"'");
return;
if (!f.open(f.exists ? 'r' : 'w+')) {
throw new Error(f.error + " (" + strerror(f.error) + ") opening '" + f.name + "'");
}
// TODO: Support requiring passwords for specific files/dirs
this.dirs = [];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment