From f60cb1a9f59d36d07129ce00b6bc2be8e9d9ecd1 Mon Sep 17 00:00:00 2001 From: Alexis Date: Tue, 7 Sep 2021 13:55:52 +0930 Subject: [PATCH] fix: invalid is not no/yes. --- app/core/states/var.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/core/states/var.ts b/app/core/states/var.ts index 4ed7d5e04..5074aa738 100644 --- a/app/core/states/var.ts +++ b/app/core/states/var.ts @@ -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),