mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-24 12:49:03 -05:00
fix: keep why a data tree or a copy failed
A damaged member of a data tree's archive (zlib.error, EOFError) ended the run on a traceback, and a failed write left its .part. --offline refusing a data tree, or the download after a --from copy failed, lost its kind, so the advice named the network instead of --offline.
This commit is contained in:
1 parent
abba99d352
commit
a296bbfdff
5 files changed
+103
-32
No files matched your search
@@ -3248,6 +3248,41 @@ class DataDirectoriesAreInstalled(unittest.TestCase):
|
||||
self.assertEqual(counts["changed"], 1)
|
||||
self.assertLess(Endless.served, 64 * 1024)
|
||||
|
||||
def test_a_damaged_member_is_a_reason_and_leaves_no_part(self):
|
||||
"""zlib.error and EOFError from a damaged member ended the run on a
|
||||
traceback, and a failed write left its .part beside the tree."""
|
||||
import zlib
|
||||
|
||||
work = Path(_tempdir(self))
|
||||
entry = self._entry()
|
||||
entry["files"] = {"Sys/GC/font.bin": {"sha1": "1" * 40, "size": 4}}
|
||||
for error in (zlib.error("invalid stored block lengths"), EOFError(),
|
||||
OSError(28, "No space left on device")):
|
||||
with self.subTest(error=type(error).__name__):
|
||||
class Broken(io.RawIOBase):
|
||||
def readable(self):
|
||||
return True
|
||||
|
||||
def readinto(self, buffer, error=error):
|
||||
raise error
|
||||
|
||||
def members(_archive, _entry):
|
||||
yield "Sys/GC/font.bin", 4, lambda: io.BufferedReader(Broken())
|
||||
|
||||
with unittest.mock.patch.object(install, "_fetch_archive",
|
||||
lambda url, d: Path(d) / "a"), \
|
||||
unittest.mock.patch.object(install, "_archive_members", members):
|
||||
counts = install.install_data_directory(entry, work)
|
||||
self.assertTrue(counts["error"])
|
||||
self.assertEqual(counts["installed"], 0)
|
||||
self.assertEqual([p.name for p in work.rglob("*.part")], [])
|
||||
|
||||
def test_offline_keeps_its_reason(self):
|
||||
work = Path(_tempdir(self))
|
||||
with unittest.mock.patch.dict(os.environ, {install.OFFLINE_VARIABLE: "1"}):
|
||||
counts = install.install_data_directory(self._entry(), work)
|
||||
self.assertIsInstance(counts["error"], install.OfflineReason)
|
||||
|
||||
def test_a_tarball_maps_through_source_path(self):
|
||||
import io as _io
|
||||
import tarfile
|
||||
|
||||
Reference in new issue
Block a user