fix: Do not backup unfinished installations (#2103)

This commit is contained in:
Kroese
2026-08-07 14:09:48 +02:00
committed by GitHub
parent b7ded137f8
commit ff8c17ad04
2 changed files with 40 additions and 8 deletions
+37 -2
View File
@@ -279,11 +279,17 @@ startInstall() {
skipInstall "$BOOT" "$previousBase" && return 1 skipInstall "$BOOT" "$previousBase" && return 1
if [ -z "$previousBase" ] && hasData; then if [ -z "$previousBase" ] && hasData; then
if enabled "$SHUTDOWN" && [ ! -f "$STORAGE/windows.boot" ]; then
discardPrevious "" || exit 50
else
if ! backupPrevious ""; then if ! backupPrevious ""; then
warn "the backup was incomplete, continuing with installation..." warn "the backup was incomplete, continuing with installation..."
fi fi
fi fi
fi
if ! makeDir "$TMP"; then if ! makeDir "$TMP"; then
error "Failed to create directory \"$TMP\" !" error "Failed to create directory \"$TMP\" !"
exit 50 exit 50
@@ -374,7 +380,7 @@ skipUnattended() {
# Preserve custom media in place. Downloaded or reused media must be moved # Preserve custom media in place. Downloaded or reused media must be moved
# back to persistent storage before the manual fallback is started. # back to persistent storage before the manual fallback is started.
useOriginalImage "$iso" useOriginalImage "$iso" || return 1
finishInstall "$BOOT" "$aborted" "$boot" && return 0 finishInstall "$BOOT" "$aborted" "$boot" && return 0
return 1 return 1
@@ -467,6 +473,11 @@ skipInstall() {
fi fi
fi fi
if enabled "$SHUTDOWN" && [ ! -f "$boot" ]; then
discardPrevious "$STORAGE/$previousBase" || exit 50
return 1
fi
info "Detected that $method, a backup of your previous installation will be saved..." info "Detected that $method, a backup of your previous installation will be saved..."
if ! backupPrevious "$STORAGE/$previousBase"; then if ! backupPrevious "$STORAGE/$previousBase"; then
@@ -624,7 +635,10 @@ removeImage() {
[ -n "$CUSTOM" ] && return 0 [ -n "$CUSTOM" ] && return 0
rm -f -- "$iso" 2>/dev/null || warn "failed to remove image \"$iso\"!" if ! rm -f -- "$iso" 2>/dev/null; then
warn "failed to remove image \"$iso\"!"
return 1
fi
return 0 return 0
} }
@@ -1264,6 +1278,27 @@ reserveSambaPorts() {
return 0 return 0
} }
discardPrevious() {
local iso="$1"
if [ -n "$iso" ] && [ -f "$iso" ]; then
if ! rm -f -- "$iso"; then
error "Failed to remove ISO file \"$iso\" !"
return 1
fi
fi
if ! find "$STORAGE" -maxdepth 1 -type f \
\( -iname 'data.*' -or -iname 'windows.*' -or -iname '*.rom' -or -iname '*.vars' \) \
-not -iname '*.iso' -delete; then
error "Failed to remove unfinished installation files from \"$STORAGE\" !"
return 1
fi
return 0
}
backupPrevious () { backupPrevious () {
local iso="$1" local iso="$1"
+1 -4
View File
@@ -1379,10 +1379,7 @@ fallbackEnglish() {
# still locate the same image, but use English installation media. # still locate the same image, but use English installation media.
LANGUAGE="en" LANGUAGE="en"
if ! rm -f -- "$iso"; then removeImage "$iso" || return 1
error "Failed to remove ISO file \"$iso\" !"
return 1
fi
downloadImage "$iso" "$version" "$LANGUAGE" downloadImage "$iso" "$version" "$LANGUAGE"
} }