this repo has no description

And so is the progress bar!

+64 -16
+3 -1
AtProtoBackup/BlobDownloader.swift
··· 59 59 pdsURL: String, 60 60 cids: [String], 61 61 saveLocationBookmark: Data? = nil, 62 - maxConcurrentDownloads: Int = 1 62 + maxConcurrentDownloads: Int = 1, 63 + progressHandler: ((Int, Int) -> Void)? = nil 63 64 ) async throws -> [URL] { 64 65 self.maxConcurrentDownloads = maxConcurrentDownloads 65 66 // Cancel any existing download task ··· 134 135 print("Download cancelled early") 135 136 } 136 137 print("Downloaded \(totalProcessed) of \(totalCIDs) blobs") 138 + progressHandler?(totalProcessed, totalCIDs) 137 139 } 138 140 139 141 return urls
+16 -1
AtProtoBackup/DownloadManager.swift
··· 30 30 let accountDid = account.did 31 31 if downloads[account.did] == nil { 32 32 downloads[account.did] = DownloadInfo(accountID: account.did) 33 + } else { 34 + // Reset progress for resume 35 + downloads[account.did]?.progress = downloads[account.did]?.progress ?? 0 33 36 } 34 37 35 38 ··· 80 83 let totalCount: Int = allBlobCids.count 81 84 await MainActor.run { 82 85 downloads[accountDid]?.totalBlobs = totalCount 86 + downloads[accountDid]?.progress = 0 // Reset progress for blob downloads 83 87 } 84 88 85 89 // guard let saveUrl = saveLocation.fileURL else { ··· 105 109 } 106 110 } 107 111 108 - let _ = try await blobDownloader.downloadBlobs(repo: account.did, pdsURL: account.pds, cids: allBlobCids, saveLocationBookmark: bookmarkData) 112 + let _ = try await blobDownloader.downloadBlobs(repo: account.did, pdsURL: account.pds, cids: allBlobCids, saveLocationBookmark: bookmarkData) { [weak self] downloaded, total in 113 + Task { @MainActor in 114 + if let totalBlobs = self?.downloads[accountDid]?.totalBlobs { 115 + self?.downloads[accountDid]?.progress = Double(downloaded) / Double(totalBlobs) 116 + } 117 + } 118 + } 119 + 120 + await MainActor.run { 121 + downloads[accountDid]?.progress = 1.0 122 + downloads[accountDid]?.isDownloading = false 123 + } 109 124 110 125 } catch { 111 126 print("Download error: \(error)")
+45 -14
AtProtoBackup/DownloadSection.swift
··· 43 43 var body: some View { 44 44 VStack(spacing: 8) { 45 45 if download.isDownloading { 46 - ProgressView(value: download.progress) { 47 - Text("Downloading... \(Int(download.progress * 100))%") 48 - .font(.caption) 46 + VStack(spacing: 4) { 47 + if let totalBlobs = download.totalBlobs { 48 + ProgressView(value: download.progress) { 49 + Text("Downloading... \(Int(download.progress * 100))%") 50 + .font(.caption) 51 + } 52 + .progressViewStyle(LinearProgressViewStyle()) 53 + 54 + Text("\(Int(download.progress * Double(totalBlobs))) of \(totalBlobs) blobs") 55 + .font(.caption2) 56 + .foregroundColor(.secondary) 57 + } else { 58 + HStack { 59 + ProgressView() 60 + .scaleEffect(0.8) 61 + Text("Fetching repository data...") 62 + .font(.caption) 63 + .foregroundColor(.secondary) 64 + } 65 + } 49 66 } 50 - .progressViewStyle(LinearProgressViewStyle()) 51 67 } else if download.progress > 0 && download.progress < 1.0 { 52 - HStack { 53 - Text("Download paused at \(Int(download.progress * 100))%") 54 - .font(.caption) 55 - .foregroundColor(.secondary) 68 + VStack(spacing: 6) { 69 + HStack { 70 + Text("Download paused at \(Int(download.progress * 100))%") 71 + .font(.caption) 72 + .foregroundColor(.secondary) 56 73 57 - Button("Resume") { 58 - downloadManager.startDownload(for: account) 74 + Button("Resume") { 75 + downloadManager.startDownload(for: account) 76 + } 77 + .buttonStyle(BorderedButtonStyle()) 78 + } 79 + 80 + if let totalBlobs = download.totalBlobs { 81 + Text("\(Int(download.progress * Double(totalBlobs))) of \(totalBlobs) blobs") 82 + .font(.caption2) 83 + .foregroundColor(.secondary) 59 84 } 60 - .buttonStyle(BorderedButtonStyle()) 61 85 } 62 86 } else if download.progress >= 1.0 { 63 87 HStack { 64 88 Image(systemName: "checkmark.circle.fill") 65 89 .foregroundColor(.green) 66 - Text("Download complete") 67 - .font(.caption) 68 - .foregroundColor(.secondary) 90 + VStack(alignment: .leading, spacing: 2) { 91 + Text("Download complete") 92 + .font(.caption) 93 + .foregroundColor(.secondary) 94 + if let totalBlobs = download.totalBlobs { 95 + Text("\(totalBlobs) blobs downloaded") 96 + .font(.caption2) 97 + .foregroundColor(.secondary) 98 + } 99 + } 69 100 } 70 101 } 71 102 }