|
1 | 1 | use crate::configuration::theseus; |
2 | | -use crate::hasher::{sha1, sha2_256, sha2_512}; |
| 2 | +use crate::hasher::{md5, sha1, sha2_256, sha2_512}; |
| 3 | +use crate::repository::maven; |
3 | 4 | use crate::Error::{PoisonedLock, UnsupportedHasher}; |
4 | 5 | use crate::Result; |
5 | 6 | use lazy_static::lazy_static; |
@@ -70,21 +71,21 @@ impl Default for HasherRegistry { |
70 | 71 | |url, extension| Ok(url.starts_with(theseus::URL) && extension == "sha256"), |
71 | 72 | sha2_256::hash, |
72 | 73 | ); |
73 | | - // The zonky maven central releases prior to version 13.2.0 only provide MD5/SHA-1 hashes. |
| 74 | + // Register the Maven hashers: https://maven.apache.org/resolver/about-checksums.html#implemented-checksum-algorithms |
74 | 75 | registry.register( |
75 | | - |url, extension| { |
76 | | - Ok(url.contains("zonky") |
77 | | - && url.contains("embedded-postgres-binaries") |
78 | | - && extension == "sha1") |
79 | | - }, |
| 76 | + |url, extension| Ok(url.starts_with(maven::URL) && extension == "md5"), |
| 77 | + md5::hash, |
| 78 | + ); |
| 79 | + registry.register( |
| 80 | + |url, extension| Ok(url.starts_with(maven::URL) && extension == "sha1"), |
80 | 81 | sha1::hash, |
81 | 82 | ); |
82 | 83 | registry.register( |
83 | | - |url, extension| { |
84 | | - Ok(url.contains("zonky") |
85 | | - && url.contains("embedded-postgres-binaries") |
86 | | - && extension == "sha512") |
87 | | - }, |
| 84 | + |url, extension| Ok(url.starts_with(maven::URL) && extension == "sha256"), |
| 85 | + sha2_256::hash, |
| 86 | + ); |
| 87 | + registry.register( |
| 88 | + |url, extension| Ok(url.starts_with(maven::URL) && extension == "sha512"), |
88 | 89 | sha2_512::hash, |
89 | 90 | ); |
90 | 91 | registry |
@@ -119,7 +120,6 @@ pub fn get<S: AsRef<str>>(url: S, extension: S) -> Result<HasherFn> { |
119 | 120 | #[cfg(test)] |
120 | 121 | mod tests { |
121 | 122 | use super::*; |
122 | | - use crate::configuration::zonky; |
123 | 123 |
|
124 | 124 | fn test_hasher(extension: &str, expected: &str) -> Result<()> { |
125 | 125 | let hasher = get("https://foo.com", extension)?; |
@@ -163,6 +163,6 @@ mod tests { |
163 | 163 |
|
164 | 164 | #[test] |
165 | 165 | fn test_get_zonkyio_postgresql_binaries() { |
166 | | - assert!(get(zonky::URL, "sha512").is_ok()); |
| 166 | + assert!(get(maven::URL, "sha512").is_ok()); |
167 | 167 | } |
168 | 168 | } |
0 commit comments