From 3a0b973c0ba19e919702a43bc6be112334ade2f4 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sun, 12 Jul 2026 21:06:05 +0200 Subject: [PATCH] feat: Use state helper for base image reads (#1839) --- src/install.sh | 73 +++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 42 deletions(-) diff --git a/src/install.sh b/src/install.sh index 2a076d6..ef8af74 100644 --- a/src/install.sh +++ b/src/install.sh @@ -11,16 +11,10 @@ backup () { local iso="$1" local name="unknown" local root="$STORAGE/backups" - local previous="$STORAGE/windows.base" + local previous - if [ -f "$previous" ]; then - - previous=$(<"$previous") - previous="${previous//[![:print:]]/}" - - [ -n "$previous" ] && name="${previous%.*}" - - fi + previous=$(readState "base") || return 1 + [ -n "$previous" ] && name="${previous%.*}" if ! makeDir "$root"; then error "Failed to create directory \"$root\" !" @@ -59,47 +53,42 @@ skipInstall() { local method="" local magic byte local boot="$STORAGE/windows.boot" - local previous="$STORAGE/windows.base" + local previous - if [ -f "$previous" ]; then + previous=$(readState "base") || return 1 - previous=$(<"$previous") - previous="${previous//[![:print:]]/}" + if [ -n "$previous" ]; then + if [[ "${STORAGE,,}/${previous,,}" != "${iso,,}" ]]; then - if [ -n "$previous" ]; then - if [[ "${STORAGE,,}/${previous,,}" != "${iso,,}" ]]; then - - if ! hasDisk; then - - rm -f "$STORAGE/$previous" - return 1 - - fi - - if [[ "${iso,,}" == "${STORAGE,,}/windows."* ]]; then - method="your custom .iso file was changed" - else - if [[ "${previous,,}" != "windows."* ]]; then - method="the VERSION variable was changed" - else - method="your custom .iso file was removed" - - if [ -f "$boot" ]; then - info "Detected that $method, will be ignored." - return 0 - fi - - fi - fi - - info "Detected that $method, a backup of your previous installation will be saved..." - ! backup "$STORAGE/$previous" && error "Backup failed!" + if ! hasDisk; then + rm -f "$STORAGE/$previous" return 1 fi - fi + if [[ "${iso,,}" == "${STORAGE,,}/windows."* ]]; then + method="your custom .iso file was changed" + else + if [[ "${previous,,}" != "windows."* ]]; then + method="the VERSION variable was changed" + else + method="your custom .iso file was removed" + + if [ -f "$boot" ]; then + info "Detected that $method, will be ignored." + return 0 + fi + + fi + fi + + info "Detected that $method, a backup of your previous installation will be saved..." + ! backup "$STORAGE/$previous" && error "Backup failed!" + + return 1 + + fi fi [ -f "$boot" ] && hasDisk && return 0