mirror of
https://codeberg.org/Toasterson/ips.git
synced 2026-04-10 13:20:42 +00:00
Refactor: Replace mutable repo assignments with immutable and enhance dependency action formatting
- Updated `FileBackend::open` calls to use immutable `repo` variables across multiple modules. - Improved dependency action string construction by integrating optional properties, predicates, and facets for better clarity and flexibility.
This commit is contained in:
parent
e236f30f6e
commit
38baf16b6f
3 changed files with 37 additions and 5 deletions
|
|
@ -530,7 +530,7 @@ impl Image {
|
|||
if origin.starts_with("file://") {
|
||||
let path_str = origin.trim_start_matches("file://");
|
||||
let path = std::path::PathBuf::from(path_str);
|
||||
let mut repo = crate::repository::FileBackend::open(&path)?;
|
||||
let repo = crate::repository::FileBackend::open(&path)?;
|
||||
repo.fetch_manifest_text(&publisher_name, fmri)?
|
||||
} else {
|
||||
let mut repo = crate::repository::RestBackend::open(origin)?;
|
||||
|
|
@ -814,7 +814,7 @@ impl Image {
|
|||
if origin.starts_with("file://") {
|
||||
let path_str = origin.trim_start_matches("file://");
|
||||
let path = PathBuf::from(path_str);
|
||||
let mut repo = FileBackend::open(&path)?;
|
||||
let repo = FileBackend::open(&path)?;
|
||||
repo.fetch_manifest(&publisher_name, fmri)
|
||||
.map_err(Into::into)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -2553,10 +2553,42 @@ impl FileBackend {
|
|||
let mut dependency_actions = Vec::new();
|
||||
for dep in &manifest.dependencies {
|
||||
if let Some(dep_fmri) = &dep.fmri {
|
||||
dependency_actions.push(format!(
|
||||
let mut action = format!(
|
||||
"depend fmri={} type={}",
|
||||
dep_fmri, dep.dependency_type
|
||||
));
|
||||
);
|
||||
|
||||
// Add predicate for conditional dependencies
|
||||
if let Some(predicate_fmri) = &dep.predicate {
|
||||
action.push_str(&format!(" predicate={}", predicate_fmri));
|
||||
}
|
||||
|
||||
// Add root-image if present
|
||||
if !dep.root_image.is_empty() {
|
||||
action.push_str(&format!(" root-image={}", dep.root_image));
|
||||
}
|
||||
|
||||
// Add any optional properties
|
||||
for prop in &dep.optional {
|
||||
action.push_str(&format!(" {}={}", prop.key, quote_action_value(&prop.value)));
|
||||
}
|
||||
|
||||
// Add facets
|
||||
for (facet_name, facet) in &dep.facets {
|
||||
action.push_str(&format!(" facet.{}={}", facet_name, quote_action_value(&facet.value)));
|
||||
}
|
||||
|
||||
// Add any optional properties
|
||||
for prop in &dep.optional {
|
||||
action.push_str(&format!(" {}={}", prop.key, quote_action_value(&prop.value)));
|
||||
}
|
||||
|
||||
// Add facets
|
||||
for (facet_name, facet) in &dep.facets {
|
||||
action.push_str(&format!(" facet.{}={}", facet_name, quote_action_value(&facet.value)));
|
||||
}
|
||||
|
||||
dependency_actions.push(action);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ impl DepotRepo {
|
|||
}
|
||||
|
||||
pub fn get_manifest_text(&self, publisher: &str, fmri: &Fmri) -> Result<String> {
|
||||
let mut backend = self
|
||||
let backend = self
|
||||
.backend
|
||||
.lock()
|
||||
.map_err(|e| DepotError::Server(format!("Lock poisoned: {}", e)))?;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue