// // DownloadTask.swift // Zyquo Local // // Author: Simon-Pierre Boucher // Mail: contact@spboucher.ai // import Foundation /// State of one model download managed by `DownloadManager` (Phase 3). struct DownloadTask: Identifiable, Codable, Hashable, Sendable { enum State: String, Codable, Sendable { case queued case downloading case paused case verifying case completed case failed case cancelled } /// Progress of a single file inside the download. struct FileProgress: Codable, Hashable, Sendable { var path: String var totalBytes: Int64 var receivedBytes: Int64 /// LFS sha256 (from x-linked-etag) when available, for integrity checks. var sha256: String? var completed: Bool } var repoID: String var state: State var files: [FileProgress] var errorDescription: String? var startedAt: Date var id: String { repoID } var totalBytes: Int64 { files.reduce(0) { $0 + $1.totalBytes } } var receivedBytes: Int64 { files.reduce(0) { $0 + $1.receivedBytes } } var fractionCompleted: Double { let total = totalBytes guard total > 0 else { return 0 } return Double(receivedBytes) / Double(total) } }