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.
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.
Fix mutability and simplify
An alternative solution.
Rebase
Remove the concept of a temporary path.
Introduce TempRepository type
To get this to work, some preparation work was required in radicle-fetch.
The first commit cleans up the use of accessing the repo directly, and uses
the Handle::repository method instead.
The second commit then refactors so that a generic AsRef<Repository> can be
used instead.
The third commit introduces a method for getting back the underlying repository.
And finally, the original commit was refactored to use a TempRepository type
for handling the clean up and move logic – so that the implementation does not
leak into radicle-node.
Rebase.