storage: Rewrite temporary repositories for clones
On Windows, all attempts to clone repositories failed with
Fetch failed for rad:… from z6Mk…: Access is denied. (os error 5)
The reason is that, other than Unix-like systems, it forbids that directories that are in use are moved.
To improve the situation, take back control over what is moved and
removed exactly by implementing cleanup instead of relying
on impl Drop for tempfile::TempDir.
fn lock_repository is renamed to fn temporary_repository because
it does not do any locking. Also, the directory name now contains “tmp”
instead of “lock”.
In the future (once Rust 1.89 is a little less cutting edge and more
widely available), we may opt for actual locking via
std::fs::File::lock.
9 files changed
+227
-120
5caa7b30
→
2149770a
modified crates/radicle-cli/tests/commands.rs
@@ -1375,7 +1375,7 @@ fn rad_clone_partial_fail() {
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
modified crates/radicle-fetch/src/handle.rs
@@ -12,9 +12,9 @@ use crate::policy::{Allowed, BlockList};
|
|
|
|
|
|
| - | |
| + | |
|
|
| - | |
| + | |
|
|
|
|
|
@@ -29,10 +29,36 @@ pub struct Handle<S> {
|
|
|
|
|
|
| - | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -40,8 +66,12 @@ impl<S> Handle<S> {
|
|
|
|
|
|
| - | |
| - | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -53,32 +83,13 @@ impl<S> Handle<S> {
|
|
|
|
|
|
| - | |
| - | |
| - | |
| - | |
| + | |
|
|
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| + | |
|
|
|
|
|
|
| - | |
| - | |
| - | |
| - | |
| - | |
| + | |
|
|
|
|
|
modified crates/radicle-fetch/src/lib.rs
@@ -16,6 +16,7 @@ use gix_protocol::handshake;
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -47,13 +48,14 @@ pub enum Error {
|
|
|
|
|
|
| - | |
| - | |
| + | |
| + | |
|
|
|
|
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -73,7 +75,7 @@ where
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -83,12 +85,13 @@ where
|
|
|
|
|
|
| - | |
| - | |
| + | |
| + | |
|
|
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -101,7 +104,7 @@ where
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -120,7 +123,7 @@ where
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
modified crates/radicle-fetch/src/sigrefs.rs
@@ -1,6 +1,7 @@
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -53,10 +54,13 @@ impl<T> DelegateStatus<T> {
|
|
|
|
|
|
| - | |
| + | |
|
|
| - | |
| - | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -102,10 +106,13 @@ impl RemoteRefs {
|
|
|
|
|
|
| - | |
| - | |
| + | |
| + | |
|
|
| - | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
modified crates/radicle-fetch/src/state.rs
@@ -8,6 +8,7 @@ use radicle::identity::{Did, Doc, DocError};
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -196,7 +197,10 @@ impl FetchState {
|
|
|
|
|
|
| - | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -207,13 +211,14 @@ impl FetchState {
|
|
|
|
|
|
| - | |
| + | |
|
|
| - | |
| + | |
|
|
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -229,7 +234,7 @@ impl FetchState {
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -261,7 +266,7 @@ impl FetchState {
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -280,9 +285,9 @@ impl FetchState {
|
|
|
|
|
|
| - | |
| + | |
|
|
| - | |
| + | |
|
|
|
|
|
@@ -291,6 +296,7 @@ impl FetchState {
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -348,15 +354,16 @@ impl FetchState {
|
|
|
|
|
|
| - | |
| + | |
|
|
| - | |
| + | |
|
|
|
|
|
|
|
|
|
|
|
|
| + | |
|
|
|
|
|
@@ -493,13 +500,14 @@ impl FetchState {
|
|
|
|
|
|
| - | |
| + | |
| + | |
|
|
|
|
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -523,9 +531,10 @@ impl FetchState {
|
|
|
|
|
|
| - | |
| + | |
| + | |
|
|
| - | |
| + | |
|
|
|
|
|
@@ -566,7 +575,7 @@ impl FetchState {
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -596,12 +605,15 @@ impl FetchState {
|
|
|
|
|
|
| - | |
| - | |
| + | |
| + | |
|
|
|
|
|
|
| - | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -613,7 +625,7 @@ impl<S> Cached<'_, S> {
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -638,8 +650,8 @@ impl<S> Cached<'_, S> {
|
|
|
|
|
|
| - | |
| - | |
| + | |
| + | |
|
|
|
|
|
@@ -649,11 +661,14 @@ impl<S> Cached<'_, S> {
|
|
|
|
|
|
| - | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -665,11 +680,14 @@ impl<S> RemoteRepository for Cached<'_, S> {
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
|
| - | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
modified crates/radicle-node/src/worker/fetch.rs
@@ -1,5 +1,6 @@
|
|
|
|
| + | |
|
|
|
|
|
@@ -27,11 +28,10 @@ use super::channels::ChannelsFlush;
|
|
|
|
|
|
| - | |
| - | |
| + | |
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -55,9 +55,9 @@ impl Handle {
|
|
|
|
|
|
| - | |
| + | |
|
|
| - | |
| + | |
|
|
|
|
|
@@ -72,11 +72,18 @@ impl Handle {
|
|
|
|
|
|
| - | |
| + | |
|
|
| - | |
| - | |
| - | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -164,35 +171,6 @@ impl Handle {
|
|
|
|
|
|
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
|
|
|
|
|
modified crates/radicle/Cargo.toml
@@ -11,7 +11,7 @@ rust-version.workspace = true
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
@@ -42,7 +42,7 @@ serde_json = { workspace = true, features = ["preserve_order"] }
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
modified crates/radicle/src/storage/git.rs
@@ -2,6 +2,9 @@
|
|
|
|
|
|
| + | |
| + | |
| + | |
|
|
|
|
|
@@ -9,7 +12,6 @@ use std::sync::LazyLock;
|
|
|
|
|
|
| - | |
|
|
|
|
|
@@ -121,9 +123,9 @@ impl ReadStorage for Storage {
|
|
|
|
|
|
| - | |
| + | |
|
|
| - | |
| + | |
|
|
|
|
|
@@ -213,23 +215,18 @@ impl Storage {
|
|
|
|
|
|
| - | |
| - | |
| - | |
| - | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
|
| - | |
| + | |
|
|
|
|
|
|
| - | |
| - | |
| - | |
| - | |
| - | |
| - | |
| + | |
|
|
|
|
|
@@ -285,6 +282,12 @@ pub struct Repository {
|
|
|
|
|
|
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
|
|
|
|
|
added crates/radicle/src/storage/git/temp.rs
@@ -0,0 +1,87 @@
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |
| + | |