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,8 +105,8 @@ impl RepoGroupManager {
// Also remove the old package archive // Also remove the old package archive
let arch_repo_pkg_dir = self.pkg_dir.join(repo).join(arch); let arch_repo_pkg_dir = self.pkg_dir.join(repo).join(arch);
for entry in arch_repo_pkg_dir.read_dir()? { arch_repo_pkg_dir.read_dir()?.try_for_each(|res| {
let entry = entry?; res.and_then(|entry: fs::DirEntry| {
let file_name = entry.file_name(); let file_name = entry.file_name();
let file_name = file_name.to_string_lossy(); let file_name = file_name.to_string_lossy();
@ -115,9 +115,12 @@ impl RepoGroupManager {
let name = name_parts[..name_parts.len() - 3].join("-"); let name = name_parts[..name_parts.len() - 3].join("-");
if name == pkg_name { if name == pkg_name {
fs::remove_file(entry.path())?; fs::remove_file(entry.path())
} } else {
Ok(())
} }
})
})?;
return Ok(true); return Ok(true);
} }
@ -166,7 +169,7 @@ impl RepoGroupManager {
} }
for arch in arch_repos.iter() { for arch in arch_repos.iter() {
self.add_pkg_in_arch_repo(repo, &arch, pkg)?; self.add_pkg_in_arch_repo(repo, arch, pkg)?;
} }
} }