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: fix component install when fail to be installed at the first time #520

Merged
merged 7 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
5 changes: 4 additions & 1 deletion src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ pub fn download_file(url: &str, path: &PathBuf) -> Result<()> {
response.into_reader().read_to_end(&mut data)?;

if let Err(e) = file.write_all(&data) {
error!(
fs::remove_file(path)?;
bail!(
"Something went wrong writing data to {}: {}",
path.display(),
e
Expand All @@ -225,12 +226,14 @@ pub fn download_file(url: &str, path: &PathBuf) -> Result<()> {
thread::sleep(Duration::from_secs(retry));
}
Err(e) => {
fs::remove_file(path)?;
// handle other status code and non-status code errors
bail!("Unexpected error: {}", e.to_string());
}
}
}

fs::remove_file(path)?;
Halimao marked this conversation as resolved.
Show resolved Hide resolved
bail!("Could not download file");
}

Expand Down
2 changes: 1 addition & 1 deletion src/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl Toolchain {
&download_cfg.name, &download_cfg.version, self.name
);

if !store.has_component(&download_cfg.name, &download_cfg.version) {
if !store.has_component(&download_cfg.name, &download_cfg.version) || !self.has_component(&download_cfg.name) {
match store.install_component(&download_cfg) {
Ok(downloaded) => {
for bin in downloaded {
Expand Down
Loading