Use separate representations for canonical repository vs. commit (#317)

Given `https://github.com/pypa/package.git#subdirectory=pkg_a` and
`https://github.com/pypa/package.git#subdirectory=pkg_b`, we want these
to map to the same shared _resource_ (for locking and cloning), but
different _packages_ (for determining whether the wheel already exists
in the cache). As such, we need two distinct concepts for "canonical
equality".

Closes #316.
This commit is contained in:
Charlie Marsh 2023-11-04 08:46:42 -07:00 committed by GitHub
parent b589813e59
commit 051188dce0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 192 additions and 25 deletions

View file

@ -22,7 +22,7 @@ use waitmap::WaitMap;
use distribution_filename::{SourceDistributionFilename, WheelFilename};
use pep508_rs::{MarkerEnvironment, Requirement};
use platform_tags::Tags;
use puffin_cache::CanonicalUrl;
use puffin_cache::RepositoryUrl;
use puffin_client::RegistryClient;
use puffin_distribution::{RemoteDistributionRef, VersionOrUrl};
use puffin_normalize::{ExtraName, PackageName};
@ -923,7 +923,7 @@ impl Locks {
/// Acquire a lock on the given resource.
async fn acquire(&self, url: &Url) -> Arc<Mutex<()>> {
let mut map = self.0.lock().await;
map.entry(puffin_cache::digest(&CanonicalUrl::new(url)))
map.entry(puffin_cache::digest(&RepositoryUrl::new(url)))
.or_insert_with(|| Arc::new(Mutex::new(())))
.clone()
}