Skip to content

Commit

Permalink
Merge pull request #21 from mario-eth/bugfix/cleaning-dependencies-on…
Browse files Browse the repository at this point in the history
…-custom-url-download

Issue #17
  • Loading branch information
mario-eth authored Nov 25, 2023
2 parents efe0ddd + 2416657 commit f5582e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/dependency_downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,18 @@ pub async fn download_dependency(
dependency_name: &String,
dependency_url: &String,
) -> Result<(), DownloadError> {
let new_path: std::path::PathBuf = get_current_working_dir().unwrap().join("dependencies");
if !new_path.is_dir() {
fs::create_dir(&new_path).unwrap();
let dependency_directory: std::path::PathBuf =
get_current_working_dir().unwrap().join("dependencies");
if !dependency_directory.is_dir() {
fs::create_dir(&dependency_directory).unwrap();
}

println!(
"Downloading dependency {} from {}",
dependency_name, dependency_url
);
let download_result: Result<(), tokio_dl_stream_to_disk::error::Error> =
AsyncDownload::new(dependency_url, &new_path, dependency_name)
AsyncDownload::new(dependency_url, &dependency_directory, dependency_name)
.download(&None)
.await;
if download_result.is_ok() {
Expand Down
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async fn main() {
version: dependency_version.clone(),
url: dependency_url.clone(),
});
if download_dependencies(&dependencies, true).await.is_err() {
if download_dependencies(&dependencies, false).await.is_err() {
eprintln!("Error downloading dependencies");
exit(500);
}
Expand Down Expand Up @@ -115,6 +115,7 @@ async fn main() {
exit(500);
}
}

// TODO this is kinda junky written, need to refactor and a better TOML writer
config::add_to_config(&dependency_name, &dependency_version, &dependency_url);

Expand All @@ -125,13 +126,15 @@ async fn main() {
exit(500);
}
}

match janitor::cleanup_dependency(&dependency_name, &dependency_version) {
Ok(_) => {}
Err(err) => {
eprintln!("Error cleanup dependency: {:?}", err);
exit(500);
}
}

if foundry_setup.remappings {
remappings();
}
Expand Down

0 comments on commit f5582e0

Please sign in to comment.