iOS transfers: 'Uploading...' then 'Uploaded' notification, and count share uploads

The Share Extension's session had no delegate, so a fast upload finished
unseen and the invalidated session was discarded before the app could hear of
it - no summary notification. Results are now handled by a shared delegate in
whichever process is alive, started/finished notifications replace each
other in place, and the app refreshes the folder the extension uploaded to.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Ayushya Amitabh
2026-10-06 19:44:19 -04:00
co-authored by Claude Sonnet 5.5
parent afc9b90963
commit 0c063c1fb4
8 changed files with 168 additions and 39 deletions
+5 -2
View File
@@ -43,8 +43,10 @@ enum ShareUpload {
static func enqueue(items: [SharedItem], account: SharedAccount, remoteFolder: String) throws {
guard !items.isEmpty else { return }
let batch = UUID().uuidString
// No delegate here: the extension is gone before the results arrive.
let session = URLSession(configuration: configuration())
// Small files can finish while the extension is still on screen; for
// those this delegate counts them. Whatever outlives the extension is
// reported to the app instead (see `TransferManager`).
let session = URLSession(configuration: configuration(), delegate: ShareUploadDelegate(), delegateQueue: nil)
var tasks: [URLSessionUploadTask] = []
for item in items {
@@ -62,6 +64,7 @@ enum ShareUpload {
TransferBatchStore.save(
TransferBatch(kind: .upload, remoteFolder: remoteFolder, total: tasks.count, succeeded: 0, failed: 0),
id: batch)
TransferNotifications.started(kind: .upload, batch: batch, count: tasks.count)
tasks.forEach { $0.resume() }
session.finishTasksAndInvalidate()
}