feat(storage): 新增只读 SMART 辅助服务与寿命通电详情

This commit is contained in:
2026-10-30 16:02:46 +08:00
parent 069e2e100f
commit 7e9728899d
25 changed files with 515 additions and 15 deletions
@@ -0,0 +1,19 @@
import Foundation
/// SMART belongs to the physical storage backing the home volume, not each APFS volume.
actor DiskHealthMonitor {
private var cached: DiskHealthMetrics?
private var nextRead: TimeInterval = 0
private var pending: Task<DiskHealthMetrics?, Never>?
func sample() async -> DiskHealthMetrics? {
if let pending { return await pending.value }
guard ProcessInfo.processInfo.systemUptime >= nextRead else { return cached }
let task = Task { await SMARTServiceClient.read() }
pending = task
cached = await task.value
pending = nil
nextRead = ProcessInfo.processInfo.systemUptime + (cached == nil ? 600 : 3600)
return cached
}
}