mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-06 10:03:49 -06:00
fix: clean download.sh staging on a failed part
This commit is contained in:
1 parent
d38cd58036
commit
df5de91b37
2 files changed
+25
-2
No files matched your search
+12
-2
@@ -29,6 +29,15 @@ case "$API_BASE" in
|
|||||||
esac
|
esac
|
||||||
API="${API_BASE%/}/repos/${REPO}/releases/latest"
|
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() {
|
usage() {
|
||||||
echo "Usage: $0 <platform> <destination>"
|
echo "Usage: $0 <platform> <destination>"
|
||||||
echo " $0 --list"
|
echo " $0 --list"
|
||||||
@@ -148,7 +157,8 @@ EOF
|
|||||||
local staging="${dest%/}/.retrobios-download"
|
local staging="${dest%/}/.retrobios-download"
|
||||||
rm -rf "$staging"
|
rm -rf "$staging"
|
||||||
mkdir -p "$staging"
|
mkdir -p "$staging"
|
||||||
trap 'rm -rf "$staging"' EXIT
|
STAGING="$staging"
|
||||||
|
trap cleanup_staging EXIT
|
||||||
|
|
||||||
local index=0
|
local index=0
|
||||||
local url name
|
local url name
|
||||||
@@ -184,7 +194,7 @@ EOF
|
|||||||
unzip -o -q "$file" -d "$dest"
|
unzip -o -q "$file" -d "$dest"
|
||||||
done
|
done
|
||||||
|
|
||||||
rm -rf "$staging"
|
cleanup_staging
|
||||||
trap - EXIT
|
trap - EXIT
|
||||||
echo "Done! BIOS files extracted to ${dest}/"
|
echo "Done! BIOS files extracted to ${dest}/"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -371,6 +371,10 @@ class ReleaseServer:
|
|||||||
]
|
]
|
||||||
self.index.write_text(json.dumps(release))
|
self.index.write_text(json.dumps(release))
|
||||||
|
|
||||||
|
def drop_last_asset(self) -> None:
|
||||||
|
"""A part the release lists but no longer serves: its URL gives 404."""
|
||||||
|
(self.root / "assets" / self.names[-1]).unlink()
|
||||||
|
|
||||||
def corrupt_last_volume(self) -> None:
|
def corrupt_last_volume(self) -> None:
|
||||||
target = self.root / "assets" / self.names[-1]
|
target = self.root / "assets" / self.names[-1]
|
||||||
target.write_bytes(target.read_bytes()[:-16] + b"0" * 16)
|
target.write_bytes(target.read_bytes()[:-16] + b"0" * 16)
|
||||||
@@ -561,6 +565,15 @@ class TestDownloadShell(DownloaderCase):
|
|||||||
proc = self.run_cli("nintendo", str(self.dest), expect_success=False)
|
proc = self.run_cli("nintendo", str(self.dest), expect_success=False)
|
||||||
self.assertIn(self.platform_label, proc.stdout + proc.stderr)
|
self.assertIn(self.platform_label, proc.stdout + proc.stderr)
|
||||||
|
|
||||||
|
def test_a_failed_part_leaves_no_staging_behind(self):
|
||||||
|
"""The EXIT trap read a variable local to the function that set it:
|
||||||
|
under set -u it failed on `staging: unbound variable` and left the
|
||||||
|
parts already downloaded in the BIOS folder."""
|
||||||
|
self.server.drop_last_asset()
|
||||||
|
proc = self.run_cli(self.platform, str(self.dest), expect_success=False)
|
||||||
|
self.assertNotIn("unbound variable", proc.stderr)
|
||||||
|
self.assertEqual(list(self.dest.iterdir()), [])
|
||||||
|
|
||||||
|
|
||||||
class TestWholePackPython(WholePackCase, TestDownloadPython):
|
class TestWholePackPython(WholePackCase, TestDownloadPython):
|
||||||
def test_info_reports_every_volume(self):
|
def test_info_reports_every_volume(self):
|
||||||
|
|||||||
Reference in new issue
Block a user