Fix loading of cached metadata for git distributions with subdirectories (#6094)

Applies the same fix as https://github.com/astral-sh/uv/issues/5944 to
cache loads

Closes https://github.com/astral-sh/uv/issues/6093
This commit is contained in:
Zanie Blue 2024-08-14 16:19:30 -05:00 committed by GitHub
parent 981b7ca5ec
commit dc67023677
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1226,12 +1226,18 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
.is_fresh()
{
if let Some(metadata) = read_cached_metadata(&metadata_entry).await? {
let path = if let Some(subdirectory) = resource.subdirectory {
Cow::Owned(fetch.path().join(subdirectory))
} else {
Cow::Borrowed(fetch.path())
};
debug!("Using cached metadata for: {source}");
return Ok(ArchiveMetadata::from(
Metadata::from_workspace(
metadata,
fetch.path(),
fetch.path(),
&path,
&path,
self.build_context.sources(),
self.preview_mode,
)