refactor(server): some functional coding
parent
d446e39253
commit
0a0a139407
|
@ -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)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue