Skip to content

Commit

Permalink
Merge pull request #40 from MordechaiHadad/fix/macos-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
MordechaiHadad authored Sep 13, 2022
2 parents 020be5f + 32b73aa commit 76cfce8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
21 changes: 15 additions & 6 deletions src/modules/expand_archive.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::models::DownloadedVersion;
use anyhow::Result;
use anyhow::{Result, anyhow};
use indicatif::{ProgressBar, ProgressStyle};
use std::cmp::min;
use std::fs::File;
Expand All @@ -8,10 +8,16 @@ use std::{fs, io};

pub async fn start(file: DownloadedVersion) -> Result<()> {
let temp_file = file.clone();
tokio::task::spawn_blocking(move || {
expand(temp_file).unwrap();
match tokio::task::spawn_blocking(move || {
match expand(temp_file) {
Ok(_) => return Ok(()),
Err(error) => return Err(anyhow!(error)),
}
})
.await?;
.await {
Ok(_) => (),
Err(error) => return Err(anyhow!(error)),
}
tokio::fs::remove_file(format!(
"{}/{}.{}",
file.path, file.file_name, file.file_format
Expand Down Expand Up @@ -85,10 +91,13 @@ fn expand(downloaded_file: DownloadedVersion) -> Result<()> {
fs::remove_dir_all(&downloaded_file.file_name)?;
}

let file = File::open(format!(
let file = match File::open(format!(
"{}.{}",
downloaded_file.file_name, downloaded_file.file_format
))?;
)) {
Ok(value) => value,
Err(error) => return Err(anyhow!("Failed to open file {}.{}, file doesn't exist. additional info: {error}", downloaded_file.file_name, downloaded_file.file_format)),
};
let decompress_stream = GzDecoder::new(file);
let mut archive = Archive::new(decompress_stream);

Expand Down
5 changes: 4 additions & 1 deletion src/modules/install_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ pub async fn start(version: &str, client: &Client, config: &Config) -> Result<In

if let Some(nightly_version) = nightly_version {
let nightly_string = serde_json::to_string(&nightly_version)?;
let mut file = fs::File::create("nightly/bob.json").await?;
let mut file = match fs::File::create("nightly/bob.json").await {
Ok(value) => value,
Err(error) => return Err(anyhow!("Failed to create file nightly/bob.json, reason: {error}")),
};
file.write_all(nightly_string.as_bytes()).await?;
}
Ok(InstallResult::InstallationSuccess(
Expand Down

0 comments on commit 76cfce8

Please sign in to comment.