Skip to content

Commit

Permalink
Make uv cache prune robust to unreadable rkyv entries (#7561)
Browse files Browse the repository at this point in the history
## Summary

We're robust to these in the rest of the CLI, but not in `uv cache
prune`.
  • Loading branch information
charliermarsh authored Sep 19, 2024
1 parent b8f9ee3 commit f9b8829
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions crates/uv-distribution/src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1806,8 +1806,7 @@ pub fn prune(cache: &Cache) -> Result<Removal, Error> {
// directories.
let revision = entry.path().join("revision.http");
if revision.is_file() {
let pointer = HttpRevisionPointer::read_from(revision)?;
if let Some(pointer) = pointer {
if let Ok(Some(pointer)) = HttpRevisionPointer::read_from(revision) {
// Remove all sibling directories that are not referenced by the pointer.
for sibling in entry.path().read_dir().map_err(Error::CacheRead)? {
let sibling = sibling.map_err(Error::CacheRead)?;
Expand All @@ -1832,8 +1831,7 @@ pub fn prune(cache: &Cache) -> Result<Removal, Error> {
// directories.
let revision = entry.path().join("revision.rev");
if revision.is_file() {
let pointer = LocalRevisionPointer::read_from(revision)?;
if let Some(pointer) = pointer {
if let Ok(Some(pointer)) = LocalRevisionPointer::read_from(revision) {
// Remove all sibling directories that are not referenced by the pointer.
for sibling in entry.path().read_dir().map_err(Error::CacheRead)? {
let sibling = sibling.map_err(Error::CacheRead)?;
Expand Down

0 comments on commit f9b8829

Please sign in to comment.