From f9b882939f3ecb75ef1fda1405f14548eaab86d7 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 19 Sep 2024 16:48:20 -0400 Subject: [PATCH] Make `uv cache prune` robust to unreadable rkyv entries (#7561) ## Summary We're robust to these in the rest of the CLI, but not in `uv cache prune`. --- crates/uv-distribution/src/source/mod.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/uv-distribution/src/source/mod.rs b/crates/uv-distribution/src/source/mod.rs index c4c40a01a..0a9c78d56 100644 --- a/crates/uv-distribution/src/source/mod.rs +++ b/crates/uv-distribution/src/source/mod.rs @@ -1806,8 +1806,7 @@ pub fn prune(cache: &Cache) -> Result { // 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)?; @@ -1832,8 +1831,7 @@ pub fn prune(cache: &Cache) -> Result { // 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)?;