mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-20 18:59:07 -05:00
chore: drop copies only an install provides
A file that arrives with the emulator is already on the user's machine and the packs leave it out. 4558 collected copies (1.4 GB) were reached only by such entries, with no platform, other profile entry or install manifest needing them. They are removed, and two release-asset copies leave the ignore list. bundled_only.py now lists every copy of a listed file, since the database keeps one path per content, and pipeline step 4d fails while one remains.
This commit is contained in:
1 parent
f71b00615d
commit
ef8b372810
4568 files changed
+291
-6121581
No files matched your search
@@ -5721,7 +5721,8 @@ class WhatOnlyAnInstallProvidesIsListed(unittest.TestCase):
|
||||
return {"path": str(path), "name": name, "sha1": sha1,
|
||||
"md5": sha1[:32], "size": path.stat().st_size}
|
||||
|
||||
db = {"files": {"a" * 40: entry("a" * 40, "icon.png"),
|
||||
db = {"bios_dir": tmp,
|
||||
"files": {"a" * 40: entry("a" * 40, "icon.png"),
|
||||
"b" * 40: entry("b" * 40, "bios.rom")},
|
||||
"indexes": {"by_name": {"icon.png": ["a" * 40], "bios.rom": ["b" * 40]},
|
||||
"by_md5": {}, "by_crc32": {}, "by_sha256": {},
|
||||
@@ -5734,6 +5735,24 @@ class WhatOnlyAnInstallProvidesIsListed(unittest.TestCase):
|
||||
rows = bundled_only.bundled_only(db, profiles, tmp, Path(tmp))
|
||||
self.assertEqual([row["path"] for row in rows], [str(Path(tmp, "icon.png"))])
|
||||
|
||||
def test_every_copy_of_the_listed_bytes_is_listed(self):
|
||||
"""The database keeps one path per content: splitwolf's sprite
|
||||
folders hold one file several times and took five passes to empty."""
|
||||
import hashlib
|
||||
import tempfile
|
||||
|
||||
import bundled_only
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp:
|
||||
for name in ("dir1/a.bmp", "dir2/a.bmp", "dir2/b.bmp"):
|
||||
Path(tmp, name).parent.mkdir(exist_ok=True)
|
||||
Path(tmp, name).write_bytes(b"same" if "a.bmp" in name else b"diff")
|
||||
sha1 = hashlib.sha1(b"same").hexdigest()
|
||||
row = {"sha1": sha1, "path": Path(tmp, "dir1/a.bmp").as_posix(), "size": 4,
|
||||
"emulators": ["splitwolf"]}
|
||||
copies = bundled_only.other_copies([row], Path(tmp))
|
||||
self.assertEqual([c["path"] for c in copies], [Path(tmp, "dir2/a.bmp").as_posix()])
|
||||
|
||||
|
||||
class TheApiSchemaHoldsTheFieldsItPromises(unittest.TestCase):
|
||||
"""The data page promises fields are only added within v1, and the
|
||||
|
||||
@@ -106,9 +106,14 @@ class TheFixedEntriesGetTheirOwnBytes(unittest.TestCase):
|
||||
e for e in document["files"]
|
||||
if (e.get("path") or e["name"]) == destination
|
||||
)
|
||||
local, _status = resolve_local_file(
|
||||
local, status = resolve_local_file(
|
||||
{**entry, "source_profile": profile}, db, dest_hint=destination
|
||||
)
|
||||
if entry.get("bundled") and entry["sha1"] not in db["files"]:
|
||||
# A bundled copy nothing else needs left the collection:
|
||||
# no other bytes may then claim to be it.
|
||||
self.assertIn(status, ("not_found", "hash_mismatch"))
|
||||
continue
|
||||
self.assertIsNotNone(local)
|
||||
self.assertEqual(
|
||||
hashlib.sha1((REPO_ROOT / local).read_bytes()).hexdigest(),
|
||||
|
||||
@@ -378,6 +378,9 @@ class ControllerDatabasesAreTheirOwn(unittest.TestCase):
|
||||
)
|
||||
with self.subTest(profile=key):
|
||||
path, status = resolve_local_file(entry, db)
|
||||
if entry.get("bundled") and entry.get("sha1") not in db["files"]:
|
||||
self.assertNotIn(status, ("sha1_exact", "md5_exact"))
|
||||
continue
|
||||
self.assertIn(status, ("sha1_exact", "md5_exact"))
|
||||
self.assertNotIn("C-Dogs", path or "")
|
||||
|
||||
@@ -447,10 +450,15 @@ class BundledFilesComeFromTheirOwnTree(unittest.TestCase):
|
||||
for owner, name in self.CASES:
|
||||
entry = next(e for e in profiles[owner]["files"] if e["name"] == name)
|
||||
with self.subTest(profile=owner, file=name):
|
||||
path, _status = resolve_local_file(
|
||||
path, status = resolve_local_file(
|
||||
dict(entry, source_profile=owner), db,
|
||||
dest_hint=entry.get("path") or entry.get("standalone_path") or "",
|
||||
)
|
||||
if entry.get("bundled") and entry.get("sha1") not in db["files"]:
|
||||
# Its own copy left the collection with the other
|
||||
# bundled-only files: another tree's file is a mismatch.
|
||||
self.assertEqual(status, "hash_mismatch" if path else "not_found")
|
||||
continue
|
||||
self.assertIn(f"/{owner}/", path or "")
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user