Skip to content

Fail gracefully when tree commit create fails #1029

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 statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

aroden-salesforce
Copy link
Contributor

Fix 1028

var result = repository.Lookup<Tree>(treeId);
if (result == null)
{
throw new LibGit2SharpException("Created tree not found! Can occur because antivirus or repo curroption");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If builder.Write is returning an ObjectId, I would expect that it exists and this test is not necessary. If builder.Write is claiming that it succeeded, but did not succeed, then we should fix that problem.

Why is it lying?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

builder.Write() does succeed and returns the correct created objectId. Lookup(id) fails because an anti-virus client blocks the read to the created object file.

It is just nicer to fail gracefully here since Lookup just returns null when the object can't be found.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahahaha. Well, it's pretty shocking that an anti-virus software would be so terrible as to put you in this situation.

That said, please don't make assumptions about why a tree wasn't found in the error message. Something more like "unable to write tree" would be more appropriate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But thanks for clarifying, indeed I misunderstood and thought the AV software was failing the write not the resultant read.

@aroden-salesforce
Copy link
Contributor Author

Attached find process monitor showing the object created successfully then the read denied. Further down the AV deletes the file and shows it in its log. Libgit2sharp null pointers during this process

block_accessed

@aroden-salesforce aroden-salesforce force-pushed the issue_1028_fail_graceful_with_av branch from c69078f to 11c700d Compare April 21, 2015 19:32
nulltoken added a commit that referenced this pull request Apr 22, 2015
…ful_with_av

Fail gracefully when tree commit create fails
@nulltoken nulltoken merged commit 16aaf6c into libgit2:vNext Apr 22, 2015
@nulltoken
Copy link
Member

🆒 Thanks!

@nulltoken nulltoken added this to the v0.22 milestone Apr 22, 2015
@ethomson
Copy link
Member

👍 Thanks @aroden-salesforce !

@nulltoken
Copy link
Member

Published as NuGet pre-release package LibGit2Sharp.0.22.0-pre20150507080442

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants