@@ -5,7 +5,8 @@ use url::Url;
5
5
6
6
use uv_configuration:: HashCheckingMode ;
7
7
use uv_distribution_types:: {
8
- DistributionMetadata , HashPolicy , Name , Resolution , UnresolvedRequirement , VersionId ,
8
+ DistributionMetadata , HashGeneration , HashPolicy , Name , Resolution , UnresolvedRequirement ,
9
+ VersionId ,
9
10
} ;
10
11
use uv_normalize:: PackageName ;
11
12
use uv_pep440:: Version ;
@@ -19,7 +20,7 @@ pub enum HashStrategy {
19
20
#[ default]
20
21
None ,
21
22
/// Hashes should be generated (specifically, a SHA-256 hash), but not validated.
22
- Generate ,
23
+ Generate ( HashGeneration ) ,
23
24
/// Hashes should be validated, if present, but ignored if absent.
24
25
///
25
26
/// If necessary, hashes should be generated to ensure that the archive is valid.
@@ -35,7 +36,7 @@ impl HashStrategy {
35
36
pub fn get < T : DistributionMetadata > ( & self , distribution : & T ) -> HashPolicy {
36
37
match self {
37
38
Self :: None => HashPolicy :: None ,
38
- Self :: Generate => HashPolicy :: Generate ,
39
+ Self :: Generate ( mode ) => HashPolicy :: Generate ( * mode ) ,
39
40
Self :: Verify ( hashes) => {
40
41
if let Some ( hashes) = hashes. get ( & distribution. version_id ( ) ) {
41
42
HashPolicy :: Validate ( hashes. as_slice ( ) )
@@ -56,7 +57,7 @@ impl HashStrategy {
56
57
pub fn get_package ( & self , name : & PackageName , version : & Version ) -> HashPolicy {
57
58
match self {
58
59
Self :: None => HashPolicy :: None ,
59
- Self :: Generate => HashPolicy :: Generate ,
60
+ Self :: Generate ( mode ) => HashPolicy :: Generate ( * mode ) ,
60
61
Self :: Verify ( hashes) => {
61
62
if let Some ( hashes) =
62
63
hashes. get ( & VersionId :: from_registry ( name. clone ( ) , version. clone ( ) ) )
@@ -79,7 +80,7 @@ impl HashStrategy {
79
80
pub fn get_url ( & self , url : & Url ) -> HashPolicy {
80
81
match self {
81
82
Self :: None => HashPolicy :: None ,
82
- Self :: Generate => HashPolicy :: Generate ,
83
+ Self :: Generate ( mode ) => HashPolicy :: Generate ( * mode ) ,
83
84
Self :: Verify ( hashes) => {
84
85
if let Some ( hashes) = hashes. get ( & VersionId :: from_url ( url) ) {
85
86
HashPolicy :: Validate ( hashes. as_slice ( ) )
@@ -100,7 +101,7 @@ impl HashStrategy {
100
101
pub fn allows_package ( & self , name : & PackageName , version : & Version ) -> bool {
101
102
match self {
102
103
Self :: None => true ,
103
- Self :: Generate => true ,
104
+ Self :: Generate ( _ ) => true ,
104
105
Self :: Verify ( _) => true ,
105
106
Self :: Require ( hashes) => {
106
107
hashes. contains_key ( & VersionId :: from_registry ( name. clone ( ) , version. clone ( ) ) )
@@ -112,7 +113,7 @@ impl HashStrategy {
112
113
pub fn allows_url ( & self , url : & Url ) -> bool {
113
114
match self {
114
115
Self :: None => true ,
115
- Self :: Generate => true ,
116
+ Self :: Generate ( _ ) => true ,
116
117
Self :: Verify ( _) => true ,
117
118
Self :: Require ( hashes) => hashes. contains_key ( & VersionId :: from_url ( url) ) ,
118
119
}
0 commit comments