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`.
This commit is contained in:
Charlie Marsh 2024-09-19 16:48:20 -04:00 committed by GitHub
parent b8f9ee3b4d
commit f9b882939f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)?;
@ -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)?;