1

I am using LibGit2Sharp to clone a remote repository into the windows temp folder. After my script has completed, I want to clean up. However, I always get the following error:

SystemError: Access to the path 'pack-efcef325f8dc897099271fd0f3db6cf4d9f12393.idx' is denied.

where pack-efcef325f8dc897099271fd0f3db6cf4d9f12393.idx is a file in $local_git_clone_path\objects\pack.

How can I completely delete all local leftovers of the git repo I cloned using LibGit2Sharp ?

abatishchev
  • 95,331
  • 80
  • 293
  • 426
Wilbert
  • 6,923
  • 6
  • 43
  • 86

1 Answers1

5

I remember having faced a similar situation.

And, as advised by @nulltoken, you would have to Dispose() the Repository before trying to delete the files that are being held by it.

using should be the best option.

using (var repo = new Repository(repositoryPath))
{
  //Your repo specific implementation.
}

//Code to Delete your local temp dir

Reference: Clone Fixture from LibGit2Sharp

nulltoken
  • 60,369
  • 19
  • 132
  • 128
jacob aloysious
  • 2,297
  • 12
  • 15