refactor todo_per_backend

This commit is contained in:
timeshifter
2023-01-14 18:03:31 +01:00
parent b0460b2c2d
commit 5a844960a8
2 changed files with 34 additions and 26 deletions
+15 -9
View File
@@ -61,14 +61,7 @@ impl Pacdef {
let mut to_install = ToDoPerBackend::new();
for backend in Backends::iter() {
let mut backend = if backend.get_section() == "pacman" {
Box::new(crate::backend::Pacman {
binary: self.config.aur_helper.clone(),
packages: HashSet::new(),
})
} else {
backend
};
let mut backend = self.overwrite_binary_from_config(backend);
backend.load(&self.groups);
@@ -81,6 +74,17 @@ impl Pacdef {
to_install
}
fn overwrite_binary_from_config(&self, backend: Box<dyn Backend>) -> Box<dyn Backend> {
if backend.get_section() == "pacman" {
Box::new(crate::backend::Pacman {
binary: self.config.aur_helper.clone(),
packages: HashSet::new(),
})
} else {
backend
}
}
fn install_packages(&self) -> Result<()> {
let to_install = self.get_missing_packages();
@@ -140,7 +144,9 @@ impl Pacdef {
fn get_unmanaged_packages(self) -> ToDoPerBackend {
let mut result = ToDoPerBackend::new();
for mut backend in Backends::iter() {
for backend in Backends::iter() {
let mut backend = self.overwrite_binary_from_config(backend);
backend.load(&self.groups);
match backend.get_unmanaged_packages_sorted() {