fix: Isolate archived ISO extraction (#2056)

This commit is contained in:
Kroese
2026-08-05 09:57:34 +02:00
committed by GitHub
parent f5c1a5c034
commit 9086a904aa
+32 -16
View File
@@ -706,6 +706,8 @@ extractImage() {
local file size local file size
local desc="local ISO" local desc="local ISO"
local archive="${dir}.archive"
local target="$dir"
if [ -z "$CUSTOM" ]; then if [ -z "$CUSTOM" ]; then
desc="downloaded ISO" desc="downloaded ISO"
@@ -722,13 +724,15 @@ extractImage() {
local msg="Extracting $desc image" local msg="Extracting $desc image"
info "$msg..." && html "$msg..." info "$msg..." && html "$msg..."
if ! rm -rf -- "$dir"; then enabled "${UNPACK:-}" && target="$archive"
error "Failed to remove directory \"$dir\" !"
if ! rm -rf -- "$dir" "$archive"; then
error "Failed to remove extraction directories!"
return 1 return 1
fi fi
if ! makeDir "$dir"; then if ! makeDir "$target"; then
error "Failed to create directory \"$dir\" !" error "Failed to create directory \"$target\" !"
return 1 return 1
fi fi
@@ -738,21 +742,23 @@ extractImage() {
fi fi
if (( size < 10000000 )); then if (( size < 10000000 )); then
error "Invalid ISO file: Size of \"$iso\" is smaller than 10 MB" && return 1 error "Invalid ISO file: Size of \"$iso\" is smaller than 10 MB"
fi
checkFreeSpace "$dir" "$size" || return 1
if ! rm -rf -- "$dir"; then
error "Failed to remove directory \"$dir\" !"
return 1 return 1
fi fi
/run/progress.sh "$dir" "$size" "$msg ([P])..." & checkFreeSpace "$target" "$size" || return 1
if ! 7z x "$iso" -o"$dir" > /dev/null; then if ! rm -rf -- "$target"; then
error "Failed to remove directory \"$target\" !"
return 1
fi
/run/progress.sh "$target" "$size" "$msg ([P])..." &
if ! 7z x "$iso" -o"$target" > /dev/null; then
fKill "progress.sh" fKill "progress.sh"
error "Failed to extract ISO file: $iso" && return 1 error "Failed to extract ISO file: $iso"
return 1
fi fi
fKill "progress.sh" fKill "progress.sh"
@@ -763,8 +769,8 @@ extractImage() {
else else
# Locate and extract the ISO nested inside the downloaded archive # Locate the first root-level ISO in the downloaded archive
if ! file=$(find "$dir" -maxdepth 1 -type f -iname "*.iso" -print -quit); then if ! file=$(find "$archive" -maxdepth 1 -type f -iname "*.iso" -print -quit); then
error "Failed to search for a nested ISO in the extracted archive!" error "Failed to search for a nested ISO in the extracted archive!"
return 1 return 1
fi fi
@@ -774,6 +780,11 @@ extractImage() {
return 1 return 1
fi fi
if ! makeDir "$dir"; then
error "Failed to create directory \"$dir\" !"
return 1
fi
if ! 7z x "$file" -o"$dir" > /dev/null; then if ! 7z x "$file" -o"$dir" > /dev/null; then
error "Failed to extract nested ISO file: $file" error "Failed to extract nested ISO file: $file"
return 1 return 1
@@ -786,6 +797,11 @@ extractImage() {
return 1 return 1
fi fi
if ! rm -rf -- "$archive"; then
error "Failed to remove directory \"$archive\" !"
return 1
fi
UNPACK="" UNPACK=""
fi fi