8000 util/win32: Continue if access is denied when deleting a folder. by lrm29 · Pull Request #6929 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content

util/win32: Continue if access is denied when deleting a folder. #6929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy st 8000 atement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

lrm29
Copy link
Contributor
@lrm29 lrm29 commented Oct 25, 2024

I'm afraid people do put Git repos on OneDrive... It seems to like to prevent folders from being deleted, causing libgit2 operations to handle ERROR_ACCESS_DENIED, and preventing us from switching branches/merging etc.

I think this change brings libgit2 in line with the behaviour of Git for Windows. The rmdir function is located here. The function is_file_in_use_error not only checks for ERROR_SHARING_VIOLATION, but also ERROR_ACCESS_DENIED:

static inline int is_file_in_use_error(DWORD errcode)
{
	switch (errcode) {
	case ERROR_SHARING_VIOLATION:
	case ERROR_ACCESS_DENIED:
		return 1;
	}

	return 0;
}

Completely understand any hesitation about merging this, but thought it might be useful to at least raise it so others can search for it. I've tried it out and it seems to work ok.

Of course, it means empty folders can end up lying around in your local Git repository which is also confusing. But Git for Windows is the same.

@ethomson
Copy link
Member

Seems reasonable!

@ethomson ethomson merged commit c6111ec into libgit2:main Oct 29, 2024
19 checks passed
@ethomson ethomson added the bug label Dec 16, 2024
@lrm29 lrm29 deleted the util_win32_rmdir_access_denied branch January 7, 2025 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0