32f129c245
## Summary Similar to `Revision`, we now store IDs in the `Archive` entires rather than absolute paths. This makes the cache robust to moves, etc. Closes https://github.com/astral-sh/uv/issues/2908.
25 lines
509 B
Rust
25 lines
509 B
Rust
use std::path::Path;
|
|
|
|
/// A unique identifier for an archive (unzipped wheel) in the cache.
|
|
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
|
pub struct ArchiveId(String);
|
|
|
|
impl Default for ArchiveId {
|
|
fn default() -> Self {
|
|
Self::new()
|
|
}
|
|
}
|
|
|
|
impl ArchiveId {
|
|
/// Generate a new unique identifier for an archive.
|
|
pub fn new() -> Self {
|
|
Self(nanoid::nanoid!())
|
|
}
|
|
}
|
|
|
|
impl AsRef<Path> for ArchiveId {
|
|
fn as_ref(&self) -> &Path {
|
|
self.0.as_ref()
|
|
}
|
|
}
|