feat: Use state helpers from base image (#1837)

This commit is contained in:
Kroese
2026-07-11 07:22:44 +03:00
committed by GitHub
parent 7a20e4aea8
commit 99c1f10263
-62
View File
@@ -185,68 +185,6 @@ startInstall() {
return 0
}
writeFile() {
local txt="$1"
local path="$2"
if ! printf '%s\n' "$txt" >"$path"; then
error "Failed to write file \"$path\" !"
return 1
fi
if ! setOwner "$path"; then
error "Failed to set the owner for \"$path\" !"
return 1
fi
return 0
}
writeState() {
local name="$1"
local value="$2"
local file="$STORAGE/windows.$name"
[ -z "$value" ] && return 0
writeFile "$value" "$file"
return $?
}
readState() {
local file="$1"
local value
[ -s "$file" ] || return 0
value=$(<"$file") || return 1
value="${value//[![:print:]]/}"
printf '%s\n' "$value"
return 0
}
restoreState() {
local var="$1"
local file="$2"
local force="${3:-N}"
local value
if ! enabled "$force"; then
[ -z "${!var:-}" ] || return 0
fi
value=$(readState "$file") || return 1
[ -n "$value" ] || return 0
printf -v "$var" '%s' "$value" || return 1
return 0
}
checkFreeSpace() {
local dir="$1"