mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-18 09:23:26 -05:00
fix: keep tree entries out of the asset store
This commit is contained in:
1 parent
faa8af0800
commit
3766588ec1
3 files changed
+33
No files matched your search
@@ -126,6 +126,10 @@ def fetch_large_file(
|
||||
turns it into the asset to fetch, and a bare name shared by several
|
||||
registered paths tries each of their assets until one verifies.
|
||||
"""
|
||||
if not name or name.endswith("/"):
|
||||
# A directory entry names a tree, never one asset: asked for
|
||||
# "caesar3/", the store answered with .cache/large/ itself.
|
||||
return None
|
||||
if registered is None:
|
||||
registered = load_registered_paths()
|
||||
for asset in asset_candidates(name, registered):
|
||||
@@ -153,6 +157,8 @@ def _fetch_asset(
|
||||
with contextlib.suppress(FileNotFoundError):
|
||||
os.unlink(path)
|
||||
|
||||
if os.path.isdir(cached):
|
||||
return None
|
||||
if os.path.exists(cached):
|
||||
try:
|
||||
hashes = compute_hashes(cached) if (expected_sha1 or expected_md5) else {}
|
||||
|
||||
@@ -210,6 +210,10 @@ def resolve_file(
|
||||
# Large files from GitHub release assets -tried when local file is
|
||||
# missing OR has a hash mismatch (wrong variant on disk)
|
||||
name = file_entry.get("name", "")
|
||||
if file_entry.get("type") == "directory" or name.endswith("/"):
|
||||
# A tree the collection does not hold is missing, as verify says;
|
||||
# the asset store holds files, not trees.
|
||||
return (path, status) if path else (None, "not_found")
|
||||
declared = _declared_hashes(file_entry)
|
||||
if file_entry.get("unsourceable") and not any(declared.values()):
|
||||
# The asset store is addressed by file name: with no hash to check,
|
||||
|
||||
@@ -3780,5 +3780,28 @@ class SignaturesCarryTheirTypes(unittest.TestCase):
|
||||
self.assertEqual(self._missing(ROOT / "scripts" / name), [])
|
||||
|
||||
|
||||
|
||||
class ATreeNobodyHoldsIsMissingNotAnAsset(unittest.TestCase):
|
||||
"""julius's caesar3/ directory, unexpanded, went to the asset store,
|
||||
which answered with .cache/large/ itself: the emulator pack died on
|
||||
IsADirectoryError where verify said MISSING."""
|
||||
|
||||
def test_directory_entries_never_reach_the_asset_store(self):
|
||||
from scripts import largefiles, packresolve
|
||||
|
||||
db = {"files": {}, "indexes": {"by_name": {}, "by_md5": {}, "by_crc32": {},
|
||||
"by_path_suffix": {}}}
|
||||
for entry in ({"name": "caesar3/", "type": "directory"}, {"name": "caesar3/"}):
|
||||
with self.subTest(entry=entry):
|
||||
self.assertEqual(
|
||||
packresolve.resolve_file(entry, db, "bios", {}, offline=True),
|
||||
(None, "not_found"),
|
||||
)
|
||||
self.assertIsNone(largefiles.fetch_large_file("caesar3/", offline=True))
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
Path(tmp, "sub").mkdir()
|
||||
self.assertIsNone(largefiles._fetch_asset("sub", tmp, "", "", offline=True))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user