@@ -418,15 +418,6 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> {
418418 dist : & BuiltDist ,
419419 hashes : HashPolicy < ' _ > ,
420420 ) -> Result < ArchiveMetadata , Error > {
421- // If the metadata was provided by the user directly, prefer it.
422- if let Some ( metadata) = self
423- . build_context
424- . dependency_metadata ( )
425- . get ( dist. name ( ) , Some ( dist. version ( ) ) )
426- {
427- return Ok ( ArchiveMetadata :: from_metadata23 ( metadata. clone ( ) ) ) ;
428- }
429-
430421 // If hash generation is enabled, and the distribution isn't hosted on a registry, get the
431422 // entire wheel to ensure that the hashes are included in the response. If the distribution
432423 // is hosted on an index, the hashes will be included in the simple metadata response.
@@ -443,14 +434,32 @@ impl<'a, Context: BuildContext> DistributionDatabase<'a, Context> {
443434 // TODO(charlie): Request the hashes via a separate method, to reduce the coupling in this API.
444435 if hashes. is_generate ( dist) {
445436 let wheel = self . get_wheel ( dist, hashes) . await ?;
446- let metadata = wheel. metadata ( ) ?;
437+ // If the metadata was provided by the user directly, prefer it.
438+ let metadata = if let Some ( metadata) = self
439+ . build_context
440+ . dependency_metadata ( )
441+ . get ( dist. name ( ) , Some ( dist. version ( ) ) )
442+ {
443+ metadata. clone ( )
444+ } else {
445+ wheel. metadata ( ) ?
446+ } ;
447447 let hashes = wheel. hashes ;
448448 return Ok ( ArchiveMetadata {
449449 metadata : Metadata :: from_metadata23 ( metadata) ,
450450 hashes,
451451 } ) ;
452452 }
453453
454+ // If the metadata was provided by the user directly, prefer it.
455+ if let Some ( metadata) = self
456+ . build_context
457+ . dependency_metadata ( )
458+ . get ( dist. name ( ) , Some ( dist. version ( ) ) )
459+ {
460+ return Ok ( ArchiveMetadata :: from_metadata23 ( metadata. clone ( ) ) ) ;
461+ }
462+
454463 let result = self
455464 . client
456465 . managed ( |client| {
0 commit comments