Refactor imports and remove unused ActionOrder implementation

- Cleaned up imports across multiple modules for better organization and removed unused dependencies.
- Eliminated `ActionOrder` implementation from `executors` as it's no longer being utilized.
- Simplified error handling in `get_dependencies` using `unwrap_or_else`.
- Optimized test setups with consistent use of `tempdir` helper function.
This commit is contained in:
Till Wegmueller 2025-08-19 11:10:36 +02:00
parent a2645749b1
commit 39124f9df4
No known key found for this signature in database
3 changed files with 14 additions and 31 deletions

View file

@ -93,17 +93,6 @@ pub enum ActionOrder {
Other = 3, Other = 3,
} }
impl ActionOrder {
fn for_manifest_section(section: &'static str) -> ActionOrder {
match section {
"dir" | "directories" => ActionOrder::Dir,
"file" | "files" => ActionOrder::File,
"link" | "links" => ActionOrder::Link,
_ => ActionOrder::Other,
}
}
}
#[derive(Debug, Default, Clone)] #[derive(Debug, Default, Clone)]
pub struct ApplyOptions { pub struct ApplyOptions {
pub dry_run: bool, pub dry_run: bool,

View file

@ -1,7 +1,7 @@
use std::path::Path; use std::path::Path;
use crate::actions::{Manifest, Dir, File, Link};
use crate::actions::executors::{apply_manifest, ApplyOptions, InstallerError}; use crate::actions::executors::{apply_manifest, ApplyOptions, InstallerError};
use crate::actions::Manifest;
use crate::solver::InstallPlan; use crate::solver::InstallPlan;
/// ActionPlan represents a merged list of actions across all manifests /// ActionPlan represents a merged list of actions across all manifests
@ -45,8 +45,7 @@ impl ActionPlan {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::solver::{InstallPlan as SInstallPlan, ResolvedPkg}; use crate::solver::InstallPlan as SInstallPlan;
use crate::fmri::{Fmri, Version};
#[test] #[test]
fn build_and_apply_empty_plan_dry_run() { fn build_and_apply_empty_plan_dry_run() {

View file

@ -16,14 +16,12 @@
//! solver, and assembles an InstallPlan from the chosen solvables. //! solver, and assembles an InstallPlan from the chosen solvables.
use std::cell::RefCell; use std::cell::RefCell;
use std::collections::{BTreeMap, HashMap, HashSet}; use std::collections::{BTreeMap, HashMap};
// Begin resolvo wiring imports (names discovered by compiler)
// We start broad and refine with compiler guidance.
use resolvo::{self, Candidates, Dependencies as RDependencies, DependencyProvider, Interner, KnownDependencies, Mapping, NameId, Problem as RProblem, Requirement as RRequirement, Solver as RSolver, SolverCache, SolvableId, StringId, VersionSetId, VersionSetUnionId, UnsolvableOrCancelled};
use miette::Diagnostic; use miette::Diagnostic;
use redb::ReadableTable; // Begin resolvo wiring imports (names discovered by compiler)
// We start broad and refine with compiler guidance.
use resolvo::{self, Candidates, Dependencies as RDependencies, DependencyProvider, Interner, KnownDependencies, Mapping, NameId, Problem as RProblem, Requirement as RRequirement, SolvableId, Solver as RSolver, SolverCache, StringId, UnsolvableOrCancelled, VersionSetId, VersionSetUnionId};
use thiserror::Error; use thiserror::Error;
use crate::actions::Manifest; use crate::actions::Manifest;
@ -298,10 +296,7 @@ impl<'a> DependencyProvider for IpsProvider<'a> {
async fn get_dependencies(&self, solvable: SolvableId) -> RDependencies { async fn get_dependencies(&self, solvable: SolvableId) -> RDependencies {
let pkg = self.solvables.get(solvable).unwrap(); let pkg = self.solvables.get(solvable).unwrap();
let fmri = &pkg.fmri; let fmri = &pkg.fmri;
let manifest_opt = match self.image.get_manifest_from_catalog(fmri) { let manifest_opt = self.image.get_manifest_from_catalog(fmri).unwrap_or_else(|_| None);
Ok(m) => m,
Err(_) => None,
};
let Some(manifest) = manifest_opt else { let Some(manifest) = manifest_opt else {
return RDependencies::Known(KnownDependencies::default()); return RDependencies::Known(KnownDependencies::default());
}; };
@ -651,12 +646,12 @@ mod tests {
#[cfg(test)] #[cfg(test)]
mod solver_integration_tests { mod solver_integration_tests {
use super::*; use super::*;
use crate::image::ImageType; use crate::actions::Dependency;
use crate::fmri::Version;
use crate::image::catalog::{CATALOG_TABLE, OBSOLETED_TABLE}; use crate::image::catalog::{CATALOG_TABLE, OBSOLETED_TABLE};
use crate::image::ImageType;
use redb::Database; use redb::Database;
use tempfile::tempdir; use tempfile::tempdir;
use crate::fmri::Version;
use crate::actions::Dependency;
fn mk_version(release: &str, branch: Option<&str>, timestamp: Option<&str>) -> Version { fn mk_version(release: &str, branch: Option<&str>, timestamp: Option<&str>) -> Version {
let mut v = Version::new(release); let mut v = Version::new(release);
@ -763,16 +758,16 @@ mod solver_integration_tests {
#[test] #[test]
fn resolve_uses_repo_manifest_after_solving() { fn resolve_uses_repo_manifest_after_solving() {
use crate::image::ImageType; use crate::image::ImageType;
use crate::repository::{FileBackend, WritableRepository, RepositoryVersion}; use crate::repository::{FileBackend, RepositoryVersion, WritableRepository};
use std::fs; use std::fs;
// Create a temp image // Create a temp image
let td_img = tempfile::tempdir().expect("tempdir img"); let td_img = tempdir().expect("tempdir img");
let img_path = td_img.path().to_path_buf(); let img_path = td_img.path().to_path_buf();
let mut img = Image::create_image(&img_path, ImageType::Partial).expect("create image"); let mut img = Image::create_image(&img_path, ImageType::Partial).expect("create image");
// Create a temp file-based repository and add publisher // Create a temp file-based repository and add publisher
let td_repo = tempfile::tempdir().expect("tempdir repo"); let td_repo = tempdir().expect("tempdir repo");
let repo_path = td_repo.path().to_path_buf(); let repo_path = td_repo.path().to_path_buf();
let mut repo = FileBackend::create(&repo_path, RepositoryVersion::V4).expect("create repo"); let mut repo = FileBackend::create(&repo_path, RepositoryVersion::V4).expect("create repo");
repo.add_publisher("pubA").expect("add publisher"); repo.add_publisher("pubA").expect("add publisher");
@ -902,9 +897,9 @@ mod solver_error_message_tests {
use super::*; use super::*;
use crate::actions::{Dependency, Manifest}; use crate::actions::{Dependency, Manifest};
use crate::fmri::{Fmri, Version}; use crate::fmri::{Fmri, Version};
use crate::image::catalog::CATALOG_TABLE;
use crate::image::ImageType; use crate::image::ImageType;
use redb::Database; use redb::Database;
use crate::image::catalog::CATALOG_TABLE;
fn mk_version(release: &str, branch: Option<&str>, timestamp: Option<&str>) -> Version { fn mk_version(release: &str, branch: Option<&str>, timestamp: Option<&str>) -> Version {
let mut v = Version::new(release); let mut v = Version::new(release);