-
Notifications
You must be signed in to change notification settings - Fork 153
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
Conversation
|
@ordian looks like this is now ready |
src/fetch.rs
Outdated
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()), | ||
} | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
This was inspired by running into errors where
cargo add inquire
wasnot 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
differentiate in our message whether we are initializing or updating.
See UI Differentiating between Initializing vs Updating frewsxcv/rust-crates-index#61
more logic