Fix catalog import logic

This commit is contained in:
Till Wegmueller 2025-08-05 00:44:29 +02:00
parent 92cce0f767
commit f2922dab11
No known key found for this signature in database
3 changed files with 20 additions and 2 deletions

View file

@ -362,8 +362,19 @@ impl ImageCatalog {
} }
// Create a catalog manager for this publisher // Create a catalog manager for this publisher
// The catalog parts are in a subdirectory: publisher/<publisher>/catalog/
let catalog_parts_dir = publisher_catalog_dir.join("publisher").join(publisher).join("catalog");
println!("Creating catalog manager for publisher: {}", publisher); println!("Creating catalog manager for publisher: {}", publisher);
let mut catalog_manager = CatalogManager::new(&publisher_catalog_dir, publisher) println!("Catalog parts directory: {:?}", catalog_parts_dir);
// Check if the catalog parts directory exists
if !catalog_parts_dir.exists() {
println!("Catalog parts directory not found: {}", catalog_parts_dir.display());
warn!("Catalog parts directory not found: {}", catalog_parts_dir.display());
continue;
}
let mut catalog_manager = CatalogManager::new(&catalog_parts_dir, publisher)
.map_err(|e| CatalogError::Repository(crate::repository::RepositoryError::Other(format!("Failed to create catalog manager: {}", e))))?; .map_err(|e| CatalogError::Repository(crate::repository::RepositoryError::Other(format!("Failed to create catalog manager: {}", e))))?;
// Get all catalog parts // Get all catalog parts

View file

@ -7,7 +7,7 @@ use std::fs;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::str::FromStr; use std::str::FromStr;
use thiserror::Error; use thiserror::Error;
use tracing::{info, warn}; use tracing::info;
/// Table definition for the installed packages database /// Table definition for the installed packages database
/// Key: full FMRI including publisher (pkg://publisher/stem@version) /// Key: full FMRI including publisher (pkg://publisher/stem@version)

View file

@ -649,6 +649,13 @@ fn main() -> Result<()> {
// List all available packages // List all available packages
info!("Listing all available packages"); info!("Listing all available packages");
// Build the catalog before querying it
info!("Building catalog...");
if let Err(e) = image.build_catalog() {
error!("Failed to build catalog: {}", e);
return Err(e.into());
}
match image.query_catalog(pattern) { match image.query_catalog(pattern) {
Ok(packages) => { Ok(packages) => {
println!("PUBLISHER NAME VERSION STATE"); println!("PUBLISHER NAME VERSION STATE");