This commit is contained in:
parent
0c47d6ccd0
commit
cb4de4dcb4
1 changed files with 24 additions and 7 deletions
|
@ -22,10 +22,18 @@ impl MirrorRepository {
|
||||||
arch: Architecture,
|
arch: Architecture,
|
||||||
) {
|
) {
|
||||||
log::info!("Downloading {url} to {}", file_path.to_str().unwrap());
|
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()
|
||||||
|
};
|
||||||
|
|
||||||
for mirror in mirrorlist {
|
for mirror in mirrorlist {
|
||||||
let mirror = mirror
|
let mirror = mirror
|
||||||
.replace("$repo", &self.inner.name)
|
.replace("$repo", &self.inner.name)
|
||||||
.replace("$arch", &arch.to_string());
|
.replace("$arch", &arch);
|
||||||
|
|
||||||
let url = format!("{mirror}/{url}");
|
let url = format!("{mirror}/{url}");
|
||||||
log::info!("Trying mirror {url}");
|
log::info!("Trying mirror {url}");
|
||||||
|
|
||||||
|
@ -44,6 +52,7 @@ impl MirrorRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log::error!("Downloading {url} failed. No mirror could provide a valid response.")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the `.db.tar.gz` content for the repository of `arch`
|
/// Get the `.db.tar.gz` content for the repository of `arch`
|
||||||
|
@ -84,12 +93,22 @@ impl MirrorRepository {
|
||||||
// PKG
|
// PKG
|
||||||
let (name, _, _, arch) = Package::extract_pkg_name(pkg_name).unwrap();
|
let (name, _, _, arch) = Package::extract_pkg_name(pkg_name).unwrap();
|
||||||
|
|
||||||
|
self.download_package(pkg_name, &name, arch, mirrorlist)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
self.inner.get_pkg(pkg_name)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn download_package(
|
||||||
|
&self,
|
||||||
|
pkg_name: &str,
|
||||||
|
name: &str,
|
||||||
|
arch: Architecture,
|
||||||
|
mirrorlist: &[String],
|
||||||
|
) {
|
||||||
self.download_file(
|
self.download_file(
|
||||||
pkg_name,
|
pkg_name,
|
||||||
self.inner
|
self.inner.base_path(arch.clone()).join(name).join(pkg_name),
|
||||||
.base_path(arch.clone())
|
|
||||||
.join(&name)
|
|
||||||
.join(pkg_name),
|
|
||||||
mirrorlist,
|
mirrorlist,
|
||||||
arch.clone(),
|
arch.clone(),
|
||||||
)
|
)
|
||||||
|
@ -107,7 +126,5 @@ impl MirrorRepository {
|
||||||
arch.clone(),
|
arch.clone(),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
self.inner.get_pkg(pkg_name)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue