mirror of
https://github.com/unraid/api.git
synced 2026-01-10 02:30:02 -06:00
fix: invalid is not no/yes.
This commit is contained in:
@@ -11,7 +11,7 @@ import { State } from './state';
|
||||
import { toNumber } from '../utils/casting';
|
||||
import { parseConfig } from '../utils/misc';
|
||||
|
||||
const iniBooleanToJsBoolean = (value: IniStringBoolean | string) => {
|
||||
const iniBooleanToJsBoolean = (value: IniStringBoolean | string, defaultValue?: any) => {
|
||||
if (value === 'no') {
|
||||
return false;
|
||||
}
|
||||
@@ -20,6 +20,10 @@ const iniBooleanToJsBoolean = (value: IniStringBoolean | string) => {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (defaultValue !== undefined) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
throw new Error(`Value "${value}" is not no/yes.`);
|
||||
};
|
||||
|
||||
@@ -227,7 +231,7 @@ const parse = (state: VarIni): Var => {
|
||||
bindMgt: iniBooleanOrAutoToJsBoolean(state.bindMgt),
|
||||
cacheNumDevices: toNumber(state.cacheNumDevices),
|
||||
cacheSbNumDisks: toNumber(state.cacheSbNumDisks),
|
||||
configValid: state.configValid === 'error' ? false : iniBooleanToJsBoolean(state.configValid),
|
||||
configValid: iniBooleanToJsBoolean(state.configValid, false),
|
||||
deviceCount: toNumber(state.deviceCount),
|
||||
fsCopyPrcnt: toNumber(state.fsCopyPrcnt),
|
||||
fsNumMounted: toNumber(state.fsNumMounted),
|
||||
|
||||
Reference in New Issue
Block a user