fix: clean download.sh staging on a failed part

This commit is contained in:
Abdessamad Derraz committed 2026-11-05 11:41:00 +01:00
1 parent d38cd58036
commit df5de91b37
2 files changed
+25 -2

No files matched your search

+12 -2
View File
@@ -29,6 +29,15 @@ case "$API_BASE" in
esac
API="${API_BASE%/}/repos/${REPO}/releases/latest"
# Global, not local to download_pack: the EXIT trap runs once that function's
# scope is gone, and under set -u a local would be unbound there.
STAGING=""
cleanup_staging() {
if [ -n "$STAGING" ]; then
rm -rf "$STAGING"
fi
}
usage() {
echo "Usage: $0 <platform> <destination>"
echo " $0 --list"
@@ -148,7 +157,8 @@ EOF
local staging="${dest%/}/.retrobios-download"
rm -rf "$staging"
mkdir -p "$staging"
trap 'rm -rf "$staging"' EXIT
STAGING="$staging"
trap cleanup_staging EXIT
local index=0
local url name
@@ -184,7 +194,7 @@ EOF
unzip -o -q "$file" -d "$dest"
done
rm -rf "$staging"
cleanup_staging
trap - EXIT
echo "Done! BIOS files extracted to ${dest}/"
}