This commit is contained in:
parent
66d53d227b
commit
36934fccfe
3 changed files with 26 additions and 6 deletions
12
Cargo.lock
generated
12
Cargo.lock
generated
|
@ -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",
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue