Skip to content
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

refactor: Punt index logic to crates-index #484

Merged
merged 1 commit into from
Aug 31, 2021

Conversation

epage
Copy link
Collaborator

@epage epage commented Aug 27, 2021

This was inspired by running into errors where cargo add inquire was
not adding the latest version. We've seen similar problems during the
development of crates-index, so hoping what they've done fixes this.

Even if it doesn't solve this problem, hopefully by nature of using a
shared crate means it will get more use and more eyes to make it more
reliable in the long term.

Handling retrying the index is annoying. I opened
frewsxcv/rust-crates-index#62

Note: in the next version of crates-index

@epage epage changed the title refactor: Pun index logic to crates-index refactor: Punt index logic to crates-index Aug 27, 2021
@epage
Copy link
Collaborator Author

epage commented Aug 27, 2021

Blocked by frewsxcv/rust-crates-index#63

@epage
Copy link
Collaborator Author

epage commented Aug 30, 2021

@ordian looks like this is now ready

src/fetch.rs Outdated
Comment on lines 126 to 136
fn need_retry(err: crates_index::Error) -> Result<bool> {
match err {
crates_index::Error::Git(err) => {
if err.class() == git2::ErrorClass::Index && err.code() == git2::ErrorCode::Locked {
Ok(true)
} else {
Err(crates_index::Error::Git(err).into())
}
}
err => Err(err.into()),
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

this function never returns Ok(false), also some docs/comments would be nice
should it take the number of attempts into consideration?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The lack of Ok(false) was more an API design than. The other patterns I had thought of for this API (like Result<()>) felt like they would be confusing in context.

I do have one idea to possibly make this a little less weird. I'll give that a try.

This was inspired by running into errors where `cargo add inquire` was
not adding the latest version.  We've seen similar problems during the
development of `crates-index`, so hoping what they've done fixes this.

Even if it doesn't solve this problem, hopefully by nature of using a
shared crate means it will get more use and more eyes to make it more
reliable in the long term.

Handling retrying the index is annoying.  I opened
frewsxcv/rust-crates-index#62

Note: in the next version of crates-index
- Opening an index will implicitly create it, so we won't be able to
  differentiate in our message whether we are initializing or updating.
  See frewsxcv/rust-crates-index#61
- We will be able to open an Index by URL, which will allow us to remove
  more logic
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.

2 participants