pub struct UpgradeConfig {
pub check_on_startup: bool,
pub check_interval: u64,
pub auto_backup: bool,
pub verify_checksum: bool,
}Expand description
Configuration settings for AGPM self-update behavior.
UpgradeConfig defines how AGPM handles automatic update checking,
backup creation, and security verification during upgrades. These settings
can be configured globally or per-project to control update behavior.
§Configuration Categories
§Update Timing
- Startup Checks: Whether to check for updates when AGPM starts
- Check Intervals: How frequently to perform background update checks
§Safety Settings
- Automatic Backups: Whether to create backups before upgrades
- Checksum Verification: Whether to verify download integrity
§Default Behavior
The default configuration prioritizes safety and user control:
- No automatic update checking on startup (avoids startup delays)
- 24-hour intervals for update checks (balances freshness with performance)
- Always create backups (enables rollback on failures)
- Always verify checksums (ensures download integrity)
§Examples
§Using Default Configuration
use agpm_cli::upgrade::config::UpgradeConfig;
let config = UpgradeConfig::default();
assert_eq!(config.check_on_startup, false);
assert_eq!(config.auto_backup, true);§Custom Configuration
use agpm_cli::upgrade::config::UpgradeConfig;
let config = UpgradeConfig {
check_on_startup: true,
check_interval: 3600, // 1 hour
auto_backup: true,
verify_checksum: true,
};§Serialization
This configuration can be serialized to TOML, JSON, or other formats supported by serde for storage in configuration files.
§TOML Example
[upgrade]
check_on_startup = false
check_interval = 86400
auto_backup = true
verify_checksum = trueFields§
§check_on_startup: boolWhether to check for updates when AGPM starts.
When enabled, AGPM will perform a background check for updates every time it starts up. This provides the earliest notification of available updates but may slightly delay startup time.
§Default: false
Disabled by default to avoid slowing down CLI operations. Users can
manually check for updates using agpm upgrade --check.
§Considerations
- Startup Performance: Adds network delay to every AGPM invocation
- Network Dependency: May fail or timeout in poor network conditions
- Rate Limiting: Frequent use may hit GitHub API rate limits
- User Experience: Can be intrusive for automated scripts
check_interval: u64Interval between automatic update checks in seconds.
Controls how frequently AGPM performs background checks for new versions. This setting balances update notification timeliness with network usage and API rate limit consumption.
§Default: 86400 (24 hours)
The default 24-hour interval provides daily update notifications while being respectful of GitHub’s API rate limits.
§Recommended Values
- 3600 (1 hour): For development environments or beta testing
- 21600 (6 hours): For active development workflows
- 86400 (1 day): Standard for most users (default)
- 604800 (1 week): For stable environments with infrequent updates
§Rate Limiting
GitHub allows 60 unauthenticated API requests per hour per IP address. Setting intervals below 1 minute may exceed rate limits with heavy usage.
auto_backup: boolWhether to automatically create backups before upgrades.
When enabled, AGPM creates a backup copy of the current binary before attempting any upgrade. This enables rollback if the upgrade fails or the new version has issues.
§Default: true
Enabled by default for maximum safety. Backups use minimal disk space and provide crucial recovery capability.
§Backup Process
- Creates a copy with
.backupsuffix in the same directory - Preserves file permissions and metadata
- Automatically removed after successful upgrades
- Can be restored manually or via
agpm upgrade --rollback
§Disabling Backups
Consider disabling only in environments where:
- Disk space is severely constrained
- File system permissions prevent backup creation
- Alternative backup/recovery mechanisms are in place
- Upgrade failures can be resolved through reinstallation
verify_checksum: boolWhether to verify checksums of downloaded binaries.
When enabled, AGPM verifies the integrity of downloaded binaries by comparing their checksums against expected values. This provides protection against corrupted downloads and potential security issues.
§Default: true
Enabled by default for security and reliability. Checksum verification adds minimal overhead but provides important integrity guarantees.
§Security Benefits
- Download Integrity: Detects corrupted or incomplete downloads
- Tamper Detection: Identifies potentially modified binaries
- Supply Chain Security: Helps ensure binary authenticity
- Network Reliability: Catches network-induced corruption
§Verification Process
- Downloads expected checksums from GitHub releases
- Computes actual checksum of downloaded binary
- Compares checksums before proceeding with installation
- Aborts upgrade if checksums don’t match
§Disabling Verification
Consider disabling only in environments where:
- Network reliability is extremely poor
- Checksum information is unavailable from releases
- Alternative integrity verification is in place
- Testing scenarios require bypassing verification
Implementations§
Source§impl UpgradeConfig
impl UpgradeConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new UpgradeConfig with default settings.
This is equivalent to Default::default() but provides a more
conventional constructor-style interface for creating configurations.
§Examples
use agpm_cli::upgrade::config::UpgradeConfig;
// These are equivalent
let config1 = UpgradeConfig::new();
let config2 = UpgradeConfig::default();
assert_eq!(config1.check_on_startup, config2.check_on_startup);
assert_eq!(config1.auto_backup, config2.auto_backup);§See Also
Default::default()- Alternative way to create default configuration
Trait Implementations§
Source§impl Clone for UpgradeConfig
impl Clone for UpgradeConfig
Source§fn clone(&self) -> UpgradeConfig
fn clone(&self) -> UpgradeConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for UpgradeConfig
impl Debug for UpgradeConfig
Source§impl Default for UpgradeConfig
impl Default for UpgradeConfig
Source§fn default() -> Self
fn default() -> Self
Create an UpgradeConfig with safe, conservative defaults.
The default configuration prioritizes safety, reliability, and user control over aggressive update checking. This approach:
- Avoids surprising users with automatic behavior
- Minimizes impact on CLI performance
- Provides maximum safety during upgrades
- Respects GitHub API rate limits
§Default Values
check_on_startup:false- No startup delayscheck_interval:86400(24 hours) - Daily update checksauto_backup:true- Always create backups for safetyverify_checksum:true- Always verify download integrity
§Examples
use agpm_cli::upgrade::config::UpgradeConfig;
let config = UpgradeConfig::default();
assert_eq!(config.check_on_startup, false);
assert_eq!(config.check_interval, 86400);
assert_eq!(config.auto_backup, true);
assert_eq!(config.verify_checksum, true);Source§impl<'de> Deserialize<'de> for UpgradeConfig
impl<'de> Deserialize<'de> for UpgradeConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for UpgradeConfig
impl RefUnwindSafe for UpgradeConfig
impl Send for UpgradeConfig
impl Sync for UpgradeConfig
impl Unpin for UpgradeConfig
impl UnwindSafe for UpgradeConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more