pub async fn install_updated_resources(
updates: &[(String, Option<String>, String, String)],
lockfile: &Arc<LockFile>,
manifest: &Manifest,
install_ctx: &InstallContext<'_>,
pb: Option<&ProgressBar>,
_quiet: bool,
) -> Result<usize>Expand description
Install only specific updated resources in parallel (selective installation).
This function provides targeted installation of only the resources that have been updated, rather than reinstalling all resources. It’s designed for efficient update operations where only a subset of dependencies have changed. The function uses the same parallel processing architecture as full installations but operates on a filtered set of resources.
§Arguments
updates- Vector of tuples containing (name,old_version,new_version) for each updated resourcelockfile- Lockfile containing all available resources (updated resources must exist here)manifest- Project manifest providing configuration and target directoriesproject_dir- Root directory where resources will be installedcache- Cache instance for Git repository and worktree managementpb- Optional progress bar for user feedback during installation_quiet- Quiet mode flag (currently unused, maintained for API compatibility)
§Update Tuple Format
Each update tuple contains:
name: Resource name as defined in the lockfileold_version: Previous version (used for logging and user feedback)new_version: New version that will be installed
§Selective Processing
The function implements selective resource processing:
- Filtering: Only processes resources listed in the
updatesvector - Lookup: Finds corresponding entries in the lockfile for each update
- Validation: Ensures all specified resources exist before processing
- Installation: Uses the same parallel architecture as full installations
§Examples
use agpm_cli::installer::{install_updated_resources, InstallContext};
use agpm_cli::lockfile::LockFile;
use agpm_cli::manifest::Manifest;
use agpm_cli::cache::Cache;
use indicatif::ProgressBar;
use std::path::Path;
use std::sync::Arc;
let lockfile = Arc::new(LockFile::load(Path::new("agpm.lock"))?);
let manifest = Manifest::load(Path::new("agpm.toml"))?;
let cache = Cache::new()?;
let pb = ProgressBar::new(3);
// Create installation context
let project_dir = Path::new(".");
let context = InstallContext::builder(project_dir, &cache).build();
// Define which resources to update
let updates = vec![
("ai-agent".to_string(), None, "v1.0.0".to_string(), "v1.1.0".to_string()),
("helper-tool".to_string(), Some("community".to_string()), "v2.0.0".to_string(), "v2.1.0".to_string()),
("data-processor".to_string(), None, "v1.5.0".to_string(), "v1.6.0".to_string()),
];
let count = install_updated_resources(
&updates,
&lockfile,
&manifest,
&context,
Some(&pb),
false
).await?;
println!("Updated {} resources", count);§Performance Benefits
Selective installation provides significant performance benefits:
- Reduced processing: Only installs resources that have actually changed
- Faster execution: Avoids redundant operations on unchanged resources
- Network efficiency: Only fetches Git data for repositories with updates
- Disk efficiency: Minimizes file system operations and cache usage
§Integration with Update Command
This function is typically used by the agpm update command after dependency
resolution determines which resources have new versions available:
Update Flow:
1. Resolve dependencies → identify version changes
2. Update lockfile → record new versions and checksums
3. Selective installation → install only changed resources§Returns
Returns the total number of resources that were successfully installed. This represents the actual number of files that were updated on disk.
§Errors
Returns an error if:
- Any specified resource name is not found in the lockfile
- Git repository access fails for resources being updated
- File system operations fail during installation
- Any individual resource installation encounters an error
The function uses atomic error handling - if any resource fails, the entire operation fails and detailed error information is provided.