pub struct UpdateManager { /* private fields */ }Expand description
Update manager implementation with full lifecycle support
Implementations§
Source§impl UpdateManager
impl UpdateManager
Sourcepub async fn new(AppState: Arc<ApplicationState>) -> Result<Self>
pub async fn new(AppState: Arc<ApplicationState>) -> Result<Self>
Create a new update manager with comprehensive initialization
Sourcepub async fn CheckForUpdates(&self) -> Result<Option<UpdateInfo>>
pub async fn CheckForUpdates(&self) -> Result<Option<UpdateInfo>>
Check for available updates from the configured update server
This method:
- Queries the update server based on the configured channel
- Validates the update against minimum compatibility requirements
- Updates the internal status with available update information
- Triggers automatic download if configured
Returns: Some(UpdateInfo) if an update is available, None otherwise
Sourcepub async fn DownloadUpdate(&self, update_info: &UpdateInfo) -> Result<()>
pub async fn DownloadUpdate(&self, update_info: &UpdateInfo) -> Result<()>
Download update package with resumable download support
This method:
- Validates available disk space before starting download
- Supports resumable downloads from network interruptions
- Tracks download progress and calculates ETA
- Updates download speed metrics
- Verifies all checksums after download
§Arguments
update_info- Update information containing download URL and metadata
§Returns
Result<()> indicating success or failure
Sourcepub async fn ApplyUpdate(&self, update_info: &UpdateInfo) -> Result<()>
pub async fn ApplyUpdate(&self, update_info: &UpdateInfo) -> Result<()>
Apply update with rollback capability
This method:
- Creates full backup of current installation
- Validates update package integrity
- Applies update atomically
- Automatically rolls back on failure
- Updates rollback history
§Arguments
update_info- Update information for the version to apply
§Returns
Result<()> indicating success or failure (with automatic rollback)
Sourcepub async fn RollbackToBackup(&self, backup_info: &RollbackState) -> Result<()>
pub async fn RollbackToBackup(&self, backup_info: &RollbackState) -> Result<()>
Sourcepub async fn RollbackToVersion(&self, version: &str) -> Result<()>
pub async fn RollbackToVersion(&self, version: &str) -> Result<()>
Sourcepub async fn GetAvailableRollbackVersions(&self) -> Vec<String>
pub async fn GetAvailableRollbackVersions(&self) -> Vec<String>
Get available rollback versions
Returns list of versions that can be rolled back to
Sourcepub async fn verify_update(
&self,
file_path: &str,
update_info: Option<&UpdateInfo>,
) -> Result<bool>
pub async fn verify_update( &self, file_path: &str, update_info: Option<&UpdateInfo>, ) -> Result<bool>
Verify update file integrity comprehensive check
This method:
- Checks file existence and non-zero size
- Verifies all checksums if UpdateInfo provided
- Detects corrupted downloads
§Arguments
file_path- Path to the update fileupdate_info- Optional update info with checksums
§Returns
Result
Sourcepub fn CompareVersions(v1: &str, v2: &str) -> i32
pub fn CompareVersions(v1: &str, v2: &str) -> i32
Sourcepub async fn GetStatus(&self) -> UpdateStatus
pub async fn GetStatus(&self) -> UpdateStatus
Get current update status
Returns a clone of the current update status
Sourcepub async fn CancelDownload(&self) -> Result<()>
pub async fn CancelDownload(&self) -> Result<()>
Cancel ongoing download
This method:
- Cancels the active download session
- Cleans up temporary files
- Updates status to paused
Sourcepub async fn ResumeDownload(&self, update_info: &UpdateInfo) -> Result<()>
pub async fn ResumeDownload(&self, update_info: &UpdateInfo) -> Result<()>
Resume paused download
This method:
- Resumes a paused download session
- Uses HTTP Range header for resume capability
§Arguments
update_info- Update information to resume download
Sourcepub async fn GetUpdateChannel(&self) -> UpdateChannel
pub async fn GetUpdateChannel(&self) -> UpdateChannel
Get update configuration
Returns the current update channel configuration
Sourcepub async fn SetUpdateChannel(&mut self, channel: UpdateChannel)
pub async fn SetUpdateChannel(&mut self, channel: UpdateChannel)
Sourcepub async fn StageUpdate(&self, update_info: &UpdateInfo) -> Result<()>
pub async fn StageUpdate(&self, update_info: &UpdateInfo) -> Result<()>
Stage update for pre-installation verification
This method:
- Stages the update in the staging directory
- Verifies the staged update
- Prepares for installation
§Arguments
update_info- Update information to stage
Sourcepub async fn CleanupOldUpdates(&self) -> Result<()>
pub async fn CleanupOldUpdates(&self) -> Result<()>
Clean up old update files
Removes downloaded updates older than a certain threshold to free disk space
Sourcepub fn GetCacheDirectory(&self) -> &PathBuf
pub fn GetCacheDirectory(&self) -> &PathBuf
Get the cache directory path
Sourcepub async fn StartBackgroundTasks(&self) -> Result<JoinHandle<()>>
pub async fn StartBackgroundTasks(&self) -> Result<JoinHandle<()>>
Start background update checking task
This method:
- Periodically checks for updates based on configured interval
- Runs in a separate tokio task
- Can be cancelled by stopping the task
§Returns
Result<tokio::task::JoinHandle<()>> - Handle to the background task
Sourcepub async fn StopBackgroundTasks(&self)
pub async fn StopBackgroundTasks(&self)
Stop background tasks
This method:
- Logs the stop request
- In production, would cancel the join handle
Trait Implementations§
Auto Trait Implementations§
impl Freeze for UpdateManager
impl !RefUnwindSafe for UpdateManager
impl Send for UpdateManager
impl Sync for UpdateManager
impl Unpin for UpdateManager
impl !UnwindSafe for UpdateManager
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].