Skip to content

Commit a23da57

Browse files
authored
Revert "sha256 for binaries index (#6241)"
This reverts commit 441473d.
1 parent 79d088f commit a23da57

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

s3_management/manage.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,14 @@ def to_simple_package_html(
382382
out.append(' <body>')
383383
out.append(' <h1>Links for {}</h1>'.format(package_name.lower().replace("_", "-")))
384384
for obj in sorted(self.gen_file_list(subdir, package_name)):
385+
385386
maybe_fragment = f"#sha256={obj.checksum}" if obj.checksum else ""
387+
388+
# Temporary skip assigning sha256 to nightly index
389+
# to be reverted on Jan 24, 2025.
390+
if subdir is not None and "nightly" in subdir:
391+
maybe_fragment = ""
392+
386393
pep658_attribute = ""
387394
if obj.pep658:
388395
pep658_sha = f"sha256={obj.pep658}"
@@ -521,7 +528,6 @@ def fetch_object_names(cls: Type[S3IndexType], prefix: str) -> List[str]:
521528

522529
def fetch_metadata(self: S3IndexType) -> None:
523530
# Add PEP 503-compatible hashes to URLs to allow clients to avoid spurious downloads, if possible.
524-
regex_multipart_upload = r"^[A-Za-z0-9+/=]+=-[0-9]+$"
525531
with concurrent.futures.ThreadPoolExecutor(max_workers=6) as executor:
526532
for idx, future in {
527533
idx: executor.submit(
@@ -534,17 +540,10 @@ def fetch_metadata(self: S3IndexType) -> None:
534540
if obj.size is None
535541
}.items():
536542
response = future.result()
537-
raw = response.get("ChecksumSHA256")
538-
if raw and match(regex_multipart_upload, raw):
539-
# Possibly part of a multipart upload, making the checksum incorrect
540-
print(f"WARNING: {self.objects[idx].orig_key} has bad checksum: {raw}")
541-
raw = None
542-
sha256 = raw and base64.b64decode(raw).hex()
543+
sha256 = (_b64 := response.get("ChecksumSHA256")) and base64.b64decode(_b64).hex()
543544
# For older files, rely on checksum-sha256 metadata that can be added to the file later
544545
if sha256 is None:
545546
sha256 = response.get("Metadata", {}).get("checksum-sha256")
546-
if sha256 is None:
547-
sha256 = response.get("Metadata", {}).get("x-amz-meta-checksum-sha256")
548547
self.objects[idx].checksum = sha256
549548
if size := response.get("ContentLength"):
550549
self.objects[idx].size = int(size)

0 commit comments

Comments
 (0)