From 2ee555df7bea383a66b54b570cb9e70cadb54c1b Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 1 Nov 2023 21:48:14 -0700 Subject: [PATCH] Use `puffin_cache::digest` in another site (#289) --- Cargo.lock | 2 -- crates/puffin-distribution/Cargo.toml | 2 -- crates/puffin-distribution/src/lib.rs | 8 +------- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 186642f30..fc3c3b56c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2100,11 +2100,9 @@ name = "puffin-distribution" version = "0.1.0" dependencies = [ "anyhow", - "hex", "pep440_rs 0.3.12", "puffin-cache", "puffin-package", - "sha2", "url", ] diff --git a/crates/puffin-distribution/Cargo.toml b/crates/puffin-distribution/Cargo.toml index e09102518..74c345a60 100644 --- a/crates/puffin-distribution/Cargo.toml +++ b/crates/puffin-distribution/Cargo.toml @@ -15,6 +15,4 @@ puffin-cache = { path = "../puffin-cache" } puffin-package = { path = "../puffin-package" } anyhow = { workspace = true } -hex = { workspace = true } -sha2 = { workspace = true } url = { workspace = true } diff --git a/crates/puffin-distribution/src/lib.rs b/crates/puffin-distribution/src/lib.rs index 4adede844..5ca3e14a3 100644 --- a/crates/puffin-distribution/src/lib.rs +++ b/crates/puffin-distribution/src/lib.rs @@ -3,7 +3,6 @@ use std::path::{Path, PathBuf}; use std::str::FromStr; use anyhow::{anyhow, Result}; -use sha2::{Digest, Sha256}; use url::Url; use pep440_rs::Version; @@ -358,12 +357,7 @@ impl<'a> RemoteDistributionRef<'a> { Self::Registry(name, version, _) => { format!("{}-{}", DistInfoName::from(*name), version) } - Self::Url(_name, url) => { - let mut hasher = Sha256::new(); - hasher.update(url.as_str().as_bytes()); - let result = hasher.finalize(); - hex::encode(result) - } + Self::Url(_name, url) => puffin_cache::digest(&CanonicalUrl::new(url)), } } }