Skip to content

Commit

Permalink
Don't emit an empty error string. (#7)
Browse files Browse the repository at this point in the history
* Don't emit an empty error string.

Allow matching the tool repo/alias as well as <author>/<repo>

Use 'stable' as the Rust version.

* rustfmt

* Revert rust-toolchain change for now.
  • Loading branch information
dsully authored Sep 16, 2023
1 parent 682e5a9 commit 94d3eee
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
15 changes: 11 additions & 4 deletions src/actions/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ pub async fn update_tools(
}
progress_bar.inc(1);
}
error!("{}", failed_tools.join("\n"));

if !failed_tools.is_empty() {
error!("{}", failed_tools.join("\n"));
}

Ok(())
}
Expand All @@ -44,11 +47,15 @@ pub async fn update_tools(
} else {
None
};
if let Some(tool) = tools.iter().find(|t| t.name == split_name[0]) {
info!("Tool: {:?}", tool);

if let Some(tool) = tools
.iter()
.find(|t| t.name == split_name[0] || t.alias == split_name[0])
{
info!("Updating: {:?}", tool);

match super::handle_tool_install(env, tool, system, version).await {
Ok(_) => info!("Tool {} has been updated.", &tool.name),
Ok(_) => info!("{} has been updated.", &tool.name),
Err(install_err) => error!("{:?}", install_err),
}
} else {
Expand Down
16 changes: 9 additions & 7 deletions src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ pub async fn download_asset<P: Into<PathBuf>>(
};
match reqwest::get(asset.browser_download_url.as_str()).await {
Ok(download_result) => match download_result.bytes().await {
Ok(download_bytes) => match async_std::fs::write(&out_file_name, download_bytes).await {
Ok(_) => Ok(out_file_name),
Err(write_err) => Err(DownloadError::FileWrite {
file_path: out_file_name,
source: write_err,
}),
},
Ok(download_bytes) => {
match async_std::fs::write(&out_file_name, download_bytes).await {
Ok(_) => Ok(out_file_name),
Err(write_err) => Err(DownloadError::FileWrite {
file_path: out_file_name,
source: write_err,
}),
}
}
Err(bytes_err) => Err(DownloadError::ResponseBytes(bytes_err)),
},
Err(down_err) => Err(DownloadError::HttpGet {
Expand Down

0 comments on commit 94d3eee

Please sign in to comment.