42 lines
1.1 KiB
Swift
42 lines
1.1 KiB
Swift
|
|
import Foundation
|
||
|
|
|
||
|
|
struct BackupResult {
|
||
|
|
let uploadedCount: Int
|
||
|
|
let skippedCount: Int
|
||
|
|
let failedCount: Int
|
||
|
|
let duration: TimeInterval
|
||
|
|
let totalBytes: Int64
|
||
|
|
let date: Date
|
||
|
|
|
||
|
|
var hasErrors: Bool { failedCount > 0 }
|
||
|
|
|
||
|
|
static func empty(date: Date = Date()) -> BackupResult {
|
||
|
|
BackupResult(uploadedCount: 0, skippedCount: 0, failedCount: 0,
|
||
|
|
duration: 0, totalBytes: 0, date: date)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
struct BackupHistoryEntry: Codable, Identifiable {
|
||
|
|
let id: UUID
|
||
|
|
let date: Date
|
||
|
|
let uploadedCount: Int
|
||
|
|
let skippedCount: Int
|
||
|
|
let failedCount: Int
|
||
|
|
let durationSeconds: Double
|
||
|
|
let totalBytes: Int64
|
||
|
|
let nasHost: String
|
||
|
|
let triggeredByLAN: Bool
|
||
|
|
|
||
|
|
init(result: BackupResult, nasHost: String, triggeredByLAN: Bool) {
|
||
|
|
self.id = UUID()
|
||
|
|
self.date = result.date
|
||
|
|
self.uploadedCount = result.uploadedCount
|
||
|
|
self.skippedCount = result.skippedCount
|
||
|
|
self.failedCount = result.failedCount
|
||
|
|
self.durationSeconds = result.duration
|
||
|
|
self.totalBytes = result.totalBytes
|
||
|
|
self.nasHost = nasHost
|
||
|
|
self.triggeredByLAN = triggeredByLAN
|
||
|
|
}
|
||
|
|
}
|