Skip to content

Conversation

@ttaylorr
Copy link
Contributor

In 1, we matched upstream Git's behavior more closely by (1) first
opening the corresponding *.idx, and then opening the associated
*.pack, skipping over any pairs which had missing/corrupt index files.

In this commit, augment that behavior by closing a file descriptor we
may have opened, but is otherwise deemed by os.Open to be unusable for
one reason or another.

This path is unlikely in practice, but is a safe change nonetheless.

/cc @git-lfs/core
/cc #8

In [1], we matched upstream Git's behavior more closely by (1) first
opening the corresponding *.idx, and _then_ opening the associated
*.pack, skipping over any pairs which had missing/corrupt index files.

In this commit, augment that behavior by closing a file descriptor we
may have opened, but is otherwise deemed by os.Open to be unusable for
one reason or another.

This path is unlikely in practice, but is a safe change nonetheless.

[1]: 561ed22 (pack/set: ignore packs without indices, 2018-11-29)
@ttaylorr ttaylorr requested a review from bk2204 January 16, 2019 02:16
// We have a pack (since it matched the regex), but the
// index is missing or unusable. Skip this pack and
// continue on with the next one, as Git does.
if idxf != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we can take this branch, since (at least from my reading of the Go source for Unix and Windows), we are guaranteed that if err is not nil, then idxf is nil (and vice versa).

Having said that, I'm not opposed to being careful here if we think that might change in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having said that, I'm not opposed to being careful here if we think that might change in the future.

This is what motivated that change here (though I should have mentioned so explicitly in my original patch, and I am sure that there are many places throughout the code that don't do this).

I agree with your reading of the implementation, but I am hesitant to drop this patch based on that alone. Since the documentation doesn't promise anything about the relation between the *os.File and error returned, I don't think that we can rely on the source alone.

Copy link
Member

Choose a reason for hiding this comment

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

Okay, I think that's fair.

@ttaylorr ttaylorr merged commit f9ae4a7 into master Jan 23, 2019
@ttaylorr ttaylorr deleted the ttaylorr-close-failed-indices branch January 23, 2019 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants