mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-02 06:18:51 -06:00
refactor: name each variant by its md5 prefix
This commit is contained in:
1 parent
f6a509aacc
commit
ed3f61db5d
321 files changed
+97
-23
No files matched your search
@@ -65,7 +65,7 @@ def place_file(
|
||||
if dest.exists() and dest.read_bytes() != data:
|
||||
# Another revision under the same name: the collection keeps it
|
||||
# beside, never in place of, the file already there.
|
||||
dest = folder / ".variants" / f"{dest.name}.{sha1[:8]}"
|
||||
dest = folder / ".variants" / f"{dest.name}.{hashlib.md5(data).hexdigest()[:8]}"
|
||||
dest.parent.mkdir(parents=True, exist_ok=True)
|
||||
with open(dest, "wb") as f:
|
||||
f.write(data)
|
||||
|
||||
@@ -104,7 +104,7 @@ def extract_from_branches(
|
||||
if file_digest(dest) == file_hash:
|
||||
existing_hashes.add(file_hash)
|
||||
continue
|
||||
dest = dest_dir / ".variants" / f"{dest.name}.{file_hash[:8]}"
|
||||
dest = dest_dir / ".variants" / f"{dest.name}.{hashlib.md5(content).hexdigest()[:8]}"
|
||||
if dest.exists():
|
||||
continue
|
||||
label = "VARIANT"
|
||||
|
||||
@@ -389,7 +389,7 @@ def _suggest_destination(review: _Review, result: ValidationResult, values: tupl
|
||||
values, result.filename, review.db, review.platform_hashes, review.profile_hashes,
|
||||
declared=bool(known.by_platform or known.by_profile),
|
||||
)
|
||||
result.destination = spot.destination(result.sha1)
|
||||
result.destination = spot.destination(result.md5)
|
||||
copies = f". --place copies it to `{result.destination}`" if result.destination else ""
|
||||
if spot.folders:
|
||||
result.add_warning(
|
||||
@@ -435,7 +435,7 @@ def _note_variant(review: _Review, result: ValidationResult, normalized: str) ->
|
||||
if not home and normalized.startswith("bios" + os.sep):
|
||||
# Beside the file, in the folder the contributor chose.
|
||||
home = os.path.dirname(normalized).replace(os.sep, "/") + "/"
|
||||
slot = f"{home}.variants/{result.filename}.{result.sha1[:8]}"
|
||||
slot = f"{home}.variants/{result.filename}.{result.md5[:8]}"
|
||||
if home and not normalized.startswith("bios" + os.sep):
|
||||
result.destination = slot
|
||||
if home:
|
||||
@@ -562,11 +562,12 @@ class Placement:
|
||||
def folder(self) -> str:
|
||||
return self.folders[0] if self.folders else self.home
|
||||
|
||||
def destination(self, sha1: str) -> str:
|
||||
def destination(self, md5: str) -> str:
|
||||
"""The path it is copied to, a variant tagged with its md5 prefix."""
|
||||
if not self.name:
|
||||
return ""
|
||||
if self.variant:
|
||||
return f"{self.folder}.variants/{self.name}.{sha1[:8]}"
|
||||
return f"{self.folder}.variants/{self.name}.{md5[:8]}"
|
||||
return self.folder + self.name
|
||||
|
||||
|
||||
|
||||
@@ -554,7 +554,7 @@ lists what else a change rewrites.
|
||||
## File conventions
|
||||
|
||||
- `bios/Manufacturer/Console/filename` for canonical files
|
||||
- `bios/Manufacturer/Console/.variants/filename.sha1prefix` for alternate versions
|
||||
- `bios/Manufacturer/Console/.variants/filename.md5prefix` for alternate versions, the first 8 hex digits of the file's md5
|
||||
- A file too large for git goes to the `large-files` GitHub release and its
|
||||
path into `.gitignore`, the list that decides what is served from the release
|
||||
- Trees addressed by path are kept out of deduplication (`NODEDUP_DIRS` in
|
||||
|
||||
@@ -363,7 +363,7 @@ def build_wanted(
|
||||
of the first emulator that reads it, else the page of the first setup
|
||||
that lists it), f folder, t the name it is uploaded under, v that name
|
||||
goes to the folder's .variants/ with the first 8 characters of its
|
||||
sha1. Entries come most useful first (_order). A file no one can share
|
||||
md5. Entries come most useful first (_order). A file no one can share
|
||||
(the reason says so, NOT_SHAREABLE) is left out.
|
||||
"""
|
||||
records = _collect_records(wanted_declarations(profiles, coverages, gap_report),
|
||||
|
||||
Reference in new issue
Block a user