|
|
|
|
@ -10,7 +10,7 @@ function getOptionOrNull(name) {
|
|
|
|
|
// e.g. in initial sync becca is not loaded because DB is not initialized
|
|
|
|
|
option = sql.getRow("SELECT * FROM options WHERE name = ?", name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return option ? option.value : null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -27,13 +27,17 @@ function getOption(name) {
|
|
|
|
|
/**
|
|
|
|
|
* @returns {number}
|
|
|
|
|
*/
|
|
|
|
|
function getOptionInt(name) {
|
|
|
|
|
function getOptionInt(name, defaultValue = undefined) {
|
|
|
|
|
const val = getOption(name);
|
|
|
|
|
|
|
|
|
|
const intVal = parseInt(val);
|
|
|
|
|
|
|
|
|
|
if (isNaN(intVal)) {
|
|
|
|
|
throw new Error(`Could not parse "${val}" into integer for option "${name}"`);
|
|
|
|
|
if (defaultValue === undefined) {
|
|
|
|
|
throw new Error(`Could not parse "${val}" into integer for option "${name}"`);
|
|
|
|
|
} else {
|
|
|
|
|
return defaultValue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return intVal;
|
|
|
|
|
|