Skip to content

Commit

Permalink
fix: new folder only after successful install
Browse files Browse the repository at this point in the history
  • Loading branch information
huyhuynh3103 committed Jun 25, 2024
1 parent a621468 commit 8e53671
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/dependency_downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ pub async fn download_dependency(
fs::create_dir(&dependency_directory).unwrap();
}

let mut file = File::create(&dependency_directory.join(dependency_name))
.await
.unwrap();
let mut stream = match reqwest::get(dependency_url).await {
Ok(res) => {
if res.status() != 200 {
Expand All @@ -102,6 +99,10 @@ pub async fn download_dependency(
}
};

let mut file = File::create(&dependency_directory.join(dependency_name))
.await
.unwrap();

while let Some(chunk_result) = stream.next().await {
match file.write_all(&chunk_result.unwrap()).await {
Ok(_) => {}
Expand Down

0 comments on commit 8e53671

Please sign in to comment.