feat: 支持在线升级功能

This commit is contained in:
mofeng-git
2026-02-11 19:41:19 +08:00
parent 60b294e0ab
commit 934dc48208
36 changed files with 945 additions and 100 deletions

View File

@@ -87,8 +87,7 @@ impl ImageManager {
.ok()
.and_then(|t| t.duration_since(std::time::UNIX_EPOCH).ok())
.map(|d| {
chrono::DateTime::from_timestamp(d.as_secs() as i64, 0)
.unwrap_or_else(Utc::now)
chrono::DateTime::from_timestamp(d.as_secs() as i64, 0).unwrap_or_else(Utc::now)
})
.unwrap_or_else(Utc::now);

View File

@@ -15,8 +15,7 @@ use crate::events::{EventBus, SystemEvent};
use crate::utils::LogThrottler;
/// MSD health status
#[derive(Debug, Clone, PartialEq)]
#[derive(Default)]
#[derive(Debug, Clone, PartialEq, Default)]
pub enum MsdHealthStatus {
/// Device is healthy and operational
#[default]
@@ -30,7 +29,6 @@ pub enum MsdHealthStatus {
},
}
/// MSD health monitor configuration
#[derive(Debug, Clone)]
pub struct MsdMonitorConfig {

View File

@@ -18,7 +18,6 @@ pub enum MsdMode {
Drive,
}
/// Image file metadata
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ImageInfo {

View File

@@ -328,9 +328,7 @@ impl VentoyDrive {
let image = match VentoyImage::open(&path) {
Ok(img) => img,
Err(e) => {
let _ = rt.block_on(tx.send(Err(std::io::Error::other(
e.to_string(),
))));
let _ = rt.block_on(tx.send(Err(std::io::Error::other(e.to_string()))));
return;
}
};
@@ -340,9 +338,7 @@ impl VentoyDrive {
// Stream the file through the writer
if let Err(e) = image.read_file_to_writer(&file_path_owned, &mut chunk_writer) {
let _ = rt.block_on(tx.send(Err(std::io::Error::other(
e.to_string(),
))));
let _ = rt.block_on(tx.send(Err(std::io::Error::other(e.to_string()))));
}
});
@@ -545,12 +541,10 @@ mod tests {
.output()?;
if !output.status.success() {
return Err(std::io::Error::other(
format!(
"xz decompress failed: {}",
String::from_utf8_lossy(&output.stderr)
),
));
return Err(std::io::Error::other(format!(
"xz decompress failed: {}",
String::from_utf8_lossy(&output.stderr)
)));
}
std::fs::write(dst, &output.stdout)?;