refactor(server): some functional coding

main
Jef Roosens 2023-07-13 22:47:08 +02:00
parent d446e39253
commit 0a0a139407
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
1 changed files with 15 additions and 12 deletions

View File

@ -105,19 +105,22 @@ impl RepoGroupManager {
// Also remove the old package archive
let arch_repo_pkg_dir = self.pkg_dir.join(repo).join(arch);
for entry in arch_repo_pkg_dir.read_dir()? {
let entry = entry?;
let file_name = entry.file_name();
let file_name = file_name.to_string_lossy();
arch_repo_pkg_dir.read_dir()?.try_for_each(|res| {
res.and_then(|entry: fs::DirEntry| {
let file_name = entry.file_name();
let file_name = file_name.to_string_lossy();
// Same trick, but for package files, we also need to trim the arch
let name_parts = file_name.split('-').collect::<Vec<_>>();
let name = name_parts[..name_parts.len() - 3].join("-");
// Same trick, but for package files, we also need to trim the arch
let name_parts = file_name.split('-').collect::<Vec<_>>();
let name = name_parts[..name_parts.len() - 3].join("-");
if name == pkg_name {
fs::remove_file(entry.path())?;
}
}
if name == pkg_name {
fs::remove_file(entry.path())
} else {
Ok(())
}
})
})?;
return Ok(true);
}
@ -166,7 +169,7 @@ impl RepoGroupManager {
}
for arch in arch_repos.iter() {
self.add_pkg_in_arch_repo(repo, &arch, pkg)?;
self.add_pkg_in_arch_repo(repo, arch, pkg)?;
}
}