ASP.NET C# app running on Windows Server 2008
I'm finding that Git .idx and .pack files to be especially resistant to programmatic deletion :
C:\github\my-org\my-repo\.git\objects\pack\pack-905fbcfd5f24c5711de900f3946b4137d26df6d5.idx
C:\github\my-org\my-repo\.git\objects\pack\pack-905fbcfd5f24c5711de900f3946b4137d26df6d5.pack
git clone
operation creates files as read-only - but even once that bit switched-off, it remains problematic to delete :
var path = @"C:\github\my-org\my-repo\.git\objects\pack\pack-33ea2068b66028f98ac9deb55c3b5d1450d65dea.idx";
File.SetAttributes(path , FileAttributes.Normal);
File.Delete(path);
File.Delete(path)
code throws exception :
Access to the path 'pack-33ea2068b66028f98ac9deb55c3b5d1450d65dea.idx' is denied.
Since the paths are not within my site dir, I'm wondering if the ASP.NET site AppPool worker-process identity needs to be explicitly assigned permissions to write/delete folders/files outside of its app domain ?
Note that on my Windows 7 local workstation, my nUnit test that invokes the delete dir operation runs green. In the debugger, I can prove that once the read-only attribute is removed from all files ( if present ), the Directory.Delete(path,true) operation does not throw.
Either a process is keeping an handle on that specific pack file (process explorer can check that for you)
Or there is a right access issue, as in libgit2sharp/issues/769:
The message looks like the one you'd get when the reason is that you're trying to remove a read-only file, which Windows does not like, and the objects git's object database (of which that index file is one) are read-only.
Removing readonly flag allows me to delete the whole directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With