Skip to content

Add HFRepository::delete_cached_revision - #207

Open
assafvayner wants to merge 3 commits into
mainfrom
assafvayner/cache-delete-api
Open

assafvayner wants to merge 3 commits into
mainfrom
assafvayner/cache-delete-api

Conversation

@assafvayner

Copy link
Copy Markdown
Contributor

Adds a public API for deleting one cached revision, so callers can reclaim cache space without reimplementing the cache layout or the downloader's blob locking.

HFRepository::delete_cached_revision (and its blocking counterpart) plans the deletion, acquires every doomed blob's lock in sorted order, removes the snapshot along with any blob no other revision references, then releases and cleans up. It returns bytes freed and whether the repo folder went away because no revisions remained.

  • Sorted lock acquisition gives all callers one global order, so two overlapping deletions cannot deadlock.
  • The set of unreferenced blobs is recomputed under lock, because a concurrent download's dedup fast path can link a new snapshot pointer onto an existing blob without taking that blob's lock.
  • Windows accounting matches the Python reference implementation: snapshot pointers are copies rather than symlinks, so a blob is only reclaimed once every revision referencing it is gone.
  • Blob locks and the lock guard type stay crate-private.

@assafvayner
assafvayner marked this pull request as ready for review September 4, 2026 05:42

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant