@@ -382,14 +382,7 @@ def to_simple_package_html(
382
382
out .append (' <body>' )
383
383
out .append (' <h1>Links for {}</h1>' .format (package_name .lower ().replace ("_" , "-" )))
384
384
for obj in sorted (self .gen_file_list (subdir , package_name )):
385
-
386
385
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
-
393
386
pep658_attribute = ""
394
387
if obj .pep658 :
395
388
pep658_sha = f"sha256={ obj .pep658 } "
@@ -528,6 +521,7 @@ def fetch_object_names(cls: Type[S3IndexType], prefix: str) -> List[str]:
528
521
529
522
def fetch_metadata (self : S3IndexType ) -> None :
530
523
# 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]+$"
531
525
with concurrent .futures .ThreadPoolExecutor (max_workers = 6 ) as executor :
532
526
for idx , future in {
533
527
idx : executor .submit (
@@ -540,10 +534,17 @@ def fetch_metadata(self: S3IndexType) -> None:
540
534
if obj .size is None
541
535
}.items ():
542
536
response = future .result ()
543
- sha256 = (_b64 := response .get ("ChecksumSHA256" )) and base64 .b64decode (_b64 ).hex ()
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 ()
544
543
# For older files, rely on checksum-sha256 metadata that can be added to the file later
545
544
if sha256 is None :
546
545
sha256 = response .get ("Metadata" , {}).get ("checksum-sha256" )
546
+ if sha256 is None :
547
+ sha256 = response .get ("Metadata" , {}).get ("x-amz-meta-checksum-sha256" )
547
548
self .objects [idx ].checksum = sha256
548
549
if size := response .get ("ContentLength" ):
549
550
self .objects [idx ].size = int (size )
0 commit comments