fix
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
JMARyA 2024-12-27 05:35:27 +01:00
parent 9ed46ba9fb
commit 3080fee86b
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263

View file

@ -55,19 +55,33 @@ impl Repository {
.ok() .ok()
} }
pub fn extract_pkg_name(name: &str) -> (String, String, String, String) {
// "{}-{}-{}-{}.pkg.tar.zst"
let splitted: Vec<&str> = name.split('-').collect();
let name = splitted.get(0).unwrap();
let version = splitted.get(1).unwrap();
let rel = splitted.get(2).unwrap();
let arch = splitted.get(3).unwrap().trim_end_matches(".pkg.tar.zst");
(
name.to_string(),
version.to_string(),
rel.to_string(),
arch.to_string(),
)
}
pub fn get_pkg(&self, arch: &str, pkg_name: &str) -> Option<Package> { pub fn get_pkg(&self, arch: &str, pkg_name: &str) -> Option<Package> {
let pkg = if pkg_name.ends_with(".pkg.tar.zst") { let pkg_name = if pkg_name.ends_with(".sig") {
Package::find(&self.name, arch, pkg_name.trim_end_matches(".pkg.tar.zst")) pkg_name.trim_end_matches(".sig").to_string()
} else if pkg_name.ends_with(".pkg.tar.zst.sig") {
Package::find(
&self.name,
arch,
pkg_name.trim_end_matches(".pkg.tar.zst.sig"),
)
} else { } else {
Package::find(&self.name, arch, pkg_name) pkg_name.to_string()
}; };
let (name, version, _, _) = Repository::extract_pkg_name(&pkg_name);
let pkg = Package::new(&self.name, &arch, &name, &version);
if pkg.exists() { if pkg.exists() {
return Some(pkg); return Some(pkg);
} else { } else {