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

fix: log warning when failing to fetch narinfo #40

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added
- [#34](https://github.com/tweag/nixtract/pull/34) add option to provide nixtract with a status communication channel
- [#36](https://github.com/tweag/nixtract/pull/36) add option to only extract runtime dependencies
- [#40](https://github.com/tweag/nixtract/pull/40) log warning when narinfo fetching fails

### Fixed
- [#38](https://github.com/tweag/nixtract/pull/38) fixed bug where found derivations were parsed incorrectly
Expand Down
16 changes: 10 additions & 6 deletions src/nix/narinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,17 @@ impl NarInfo {
);

log::info!("Fetching narinfo from {}", url);
if let Ok(response) = reqwest::blocking::get(&url) {
if response.status().is_success() {
let narinfo = response.text()?;
return Ok(Some(Self::parse(&narinfo)?));
} else {
log::warn!("Cache responded with error code: {}", response.status());
match reqwest::blocking::get(&url) {
Ok(response) => {
if response.status().is_success() {
let narinfo = response.text()?;
let narinfo = Self::parse(&narinfo)?;
return Ok(Some(narinfo));
} else {
log::warn!("Cache responded with error code: {}", response.status());
}
}
Err(err) => log::warn!("Could not fetch narinfo: {}", err),
}
}

Expand Down
Loading