Skip to content

Commit

Permalink
Fix 'PermissionDenied' during rename of temporary clone directory (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
sceneq authored Feb 11, 2023
1 parent c1dbd3b commit 6751f79
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/lock/source/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ fn checkout(
fn install(ctx: &Context, dir: PathBuf, url: &Url, checkout: GitCheckout) -> Result<LockedSource> {
let temp_dir =
TempPath::new_force(&dir).context("failed to prepare temporary clone directory")?;
let repo = git::clone(url, temp_dir.path())?;
git::checkout(&repo, checkout.resolve(&repo)?)?;
git::submodule_update(&repo).context("failed to recursively update")?;
{
let repo = git::clone(url, temp_dir.path())?;
git::checkout(&repo, checkout.resolve(&repo)?)?;
git::submodule_update(&repo).context("failed to recursively update")?;
} // `repo` must be dropped before renaming the directory
temp_dir
.rename(&dir)
.context("failed to rename temporary clone directory")?;
Expand Down

0 comments on commit 6751f79

Please sign in to comment.