refactor(server): some functional coding
parent
d446e39253
commit
0a0a139407
|
@ -105,19 +105,22 @@ 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();
|
||||||
|
|
||||||
// Same trick, but for package files, we also need to trim the arch
|
// Same trick, but for package files, we also need to trim the arch
|
||||||
let name_parts = file_name.split('-').collect::<Vec<_>>();
|
let name_parts = file_name.split('-').collect::<Vec<_>>();
|
||||||
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)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue