diff --git a/Cargo.lock b/Cargo.lock index aac79c3..953178d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -135,6 +135,17 @@ dependencies = [ "serde", ] +[[package]] +name = "async-recursion" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "async-stream" version = "0.3.6" @@ -1976,6 +1987,7 @@ name = "pacco" version = "0.1.0" dependencies = [ "argh", + "async-recursion", "based", "bytesize", "chrono", diff --git a/Cargo.toml b/Cargo.toml index c6850e0..9cef90c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,3 +31,4 @@ zstd = "0.13.2" argh = "0.1.13" cmd_lib = "1.9.5" nix = { version = "0.29.0", features = ["user"] } +async-recursion = "1.1.1" diff --git a/src/pkg/mirror.rs b/src/pkg/mirror.rs index b0535c3..355dcb7 100644 --- a/src/pkg/mirror.rs +++ b/src/pkg/mirror.rs @@ -1,5 +1,6 @@ use std::path::PathBuf; +use async_recursion::async_recursion; use comrade::rally; use crate::config::Mirrorlist; @@ -18,6 +19,7 @@ impl MirrorRepository { } } + #[async_recursion] pub async fn download_file( &self, url: &str, @@ -27,11 +29,14 @@ impl MirrorRepository { ) { log::info!("Downloading {url} to {}", file_path.to_str().unwrap()); - let arch = if matches!(arch, Architecture::any) { - Architecture::x86_64.to_string() // `any` packages dont get served under repo "any" for some reason - } else { - arch.to_string() - }; + if matches!(arch, Architecture::any) { + // `any` packages dont get served under repo "any" for some reason + self.download_file(url, file_path.clone(), mirrorlist, Architecture::x86_64) + .await; + self.download_file(url, file_path, mirrorlist, Architecture::aarch64) + .await; + return; + } let parent = file_path.parent().unwrap(); std::fs::create_dir_all(parent).unwrap(); @@ -40,7 +45,9 @@ impl MirrorRepository { .into_iter() .take(5) .map(|x| { - let mirror = x.replace("$repo", &self.inner.name).replace("$arch", &arch); + let mirror = x + .replace("$repo", &self.inner.name) + .replace("$arch", &arch.to_string()); ( x.clone(),