mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-06 01:53:56 -06:00
fix: give each download.sh run its own staging
This commit is contained in:
1 parent
df5de91b37
commit
34293f7bbb
2 files changed
+34
-4
No files matched your search
+5
-4
@@ -152,11 +152,12 @@ EOF
|
||||
fi
|
||||
|
||||
# Staged inside the destination: a pack is gigabytes, and /tmp is a RAM
|
||||
# disk on the appliances these packs target.
|
||||
# disk on the appliances these packs target. The folder is this run's own:
|
||||
# a fixed name let a second download into the same folder empty it while
|
||||
# the first was still writing its parts.
|
||||
mkdir -p "$dest"
|
||||
local staging="${dest%/}/.retrobios-download"
|
||||
rm -rf "$staging"
|
||||
mkdir -p "$staging"
|
||||
local staging
|
||||
staging=$(mktemp -d "${dest%/}/.retrobios-download-XXXXXX")
|
||||
STAGING="$staging"
|
||||
trap cleanup_staging EXIT
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import threading
|
||||
import time
|
||||
import unittest
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
@@ -574,6 +575,34 @@ class TestDownloadShell(DownloaderCase):
|
||||
self.assertNotIn("unbound variable", proc.stderr)
|
||||
self.assertEqual(list(self.dest.iterdir()), [])
|
||||
|
||||
def test_two_runs_into_one_folder_both_finish(self):
|
||||
"""Both runs staged in `<dest>/.retrobios-download` and the second
|
||||
emptied it while the first was still writing its parts."""
|
||||
shim = Path(_tempdir(self))
|
||||
real = shutil.which("curl")
|
||||
(shim / "curl").write_text(
|
||||
"#!/bin/sh\n"
|
||||
'case "$*" in *-o*) sleep 1 ;; esac\n'
|
||||
f'exec "{real}" "$@"\n'
|
||||
)
|
||||
(shim / "curl").chmod(0o755)
|
||||
env = self.env()
|
||||
env["PATH"] = f"{shim}{os.pathsep}{env['PATH']}"
|
||||
command = ["bash", str(SHELL), self.platform, str(self.dest)]
|
||||
first = subprocess.Popen(
|
||||
command, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
)
|
||||
time.sleep(0.5)
|
||||
second = subprocess.run(
|
||||
command, env=env, capture_output=True, text=True, timeout=120
|
||||
)
|
||||
out, err = first.communicate(timeout=120)
|
||||
self.assertEqual(first.returncode, 0, out + err)
|
||||
self.assertEqual(second.returncode, 0, second.stdout + second.stderr)
|
||||
self.assert_extracted()
|
||||
self.assert_no_leftovers()
|
||||
|
||||
|
||||
class TestWholePackPython(WholePackCase, TestDownloadPython):
|
||||
def test_info_reports_every_volume(self):
|
||||
|
||||
Reference in new issue
Block a user