mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-09 18:12:07 +00:00
Restructure Git cache to include package name (#588)
## Summary This PR modifies the Git wheel cache to: (1) use a shorter version of the SHA, to save space; and (2) include the package name, for consistency with all other buckets. I considered removing the URL hash entirely, and _just_ using the SHA, which would be even _more_ consistent with other buckets. But if we remove the URL, then we won't have separate directories for subdirectories (which are part of the URL). Before: <img width="1035" alt="Screen Shot 2023-12-07 at 7 23 42 PM" src="86afce67
-682f-464f-9ba1-0b60d5b7f19f"> After: <img width="1232" alt="Screen Shot 2023-12-07 at 8 09 23 PM" src="eda42a19
-974f-47fe-8c83-54a602ddfd2d">
This commit is contained in:
parent
ef7be9103c
commit
5ae3a8b1cb
7 changed files with 74 additions and 29 deletions
|
@ -11,7 +11,7 @@ use url::Url;
|
|||
use puffin_cache::{digest, RepositoryUrl};
|
||||
|
||||
use crate::git::GitRemote;
|
||||
use crate::{FetchStrategy, GitUrl};
|
||||
use crate::{FetchStrategy, GitSha, GitUrl};
|
||||
|
||||
/// A remote Git source that can be checked out locally.
|
||||
pub struct GitSource {
|
||||
|
@ -58,7 +58,7 @@ impl GitSource {
|
|||
let (db, actual_rev, task) = match (self.git.precise, remote.db_at(&db_path).ok()) {
|
||||
// If we have a locked revision, and we have a preexisting database
|
||||
// which has that revision, then no update needs to happen.
|
||||
(Some(rev), Some(db)) if db.contains(rev) => (db, rev, None),
|
||||
(Some(rev), Some(db)) if db.contains(rev.into()) => (db, rev, None),
|
||||
|
||||
// ... otherwise we use this state to update the git database. Note
|
||||
// that we still check for being offline here, for example in the
|
||||
|
@ -76,18 +76,18 @@ impl GitSource {
|
|||
&db_path,
|
||||
db,
|
||||
&self.git.reference,
|
||||
locked_rev,
|
||||
locked_rev.map(git2::Oid::from),
|
||||
self.strategy,
|
||||
&self.client,
|
||||
)?;
|
||||
|
||||
(db, actual_rev, task)
|
||||
(db, GitSha::from(actual_rev), task)
|
||||
}
|
||||
};
|
||||
|
||||
// Don’t use the full hash, in order to contribute less to reaching the
|
||||
// path length limit on Windows.
|
||||
let short_id = db.to_short_id(actual_rev)?;
|
||||
let short_id = db.to_short_id(actual_rev.into())?;
|
||||
|
||||
// Check out `actual_rev` from the database to a scoped location on the
|
||||
// filesystem. This will use hard links and such to ideally make the
|
||||
|
@ -97,7 +97,12 @@ impl GitSource {
|
|||
.join("checkouts")
|
||||
.join(&ident)
|
||||
.join(short_id.as_str());
|
||||
db.copy_to(actual_rev, &checkout_path, self.strategy, &self.client)?;
|
||||
db.copy_to(
|
||||
actual_rev.into(),
|
||||
&checkout_path,
|
||||
self.strategy,
|
||||
&self.client,
|
||||
)?;
|
||||
|
||||
// Report the checkout operation to the reporter.
|
||||
if let Some(task) = task {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue