Update OTG transfer workflow

This commit is contained in:
2026-07-10 11:02:00 +08:00
parent 9d446b4bc3
commit 98dc810455
11 changed files with 1047 additions and 121 deletions

View File

@ -18,7 +18,7 @@ enum TravelAlbumCameraImportState: Equatable {
case loading
case loaded(sections: [TravelAlbumCameraImportSection])
case importing(current: Int, total: Int)
case finished(importedCount: Int, failedCount: Int)
case finished(importedCount: Int, failedCount: Int, importedPhotoIds: [String])
case failed(message: String)
}
@ -180,6 +180,7 @@ final class TravelAlbumCameraImportViewModel {
Task {
let directory = try? storage.originalsDirectory(albumId: albumId)
var importedCount = 0
var importedPhotoIds: [String] = []
for (index, object) in selected.enumerated() {
defer { state = .importing(current: index + 1, total: selected.count) }
@ -204,6 +205,7 @@ final class TravelAlbumCameraImportViewModel {
)
storage.upsert(record, albumId: albumId)
existingPhotoIds.insert(object.id)
importedPhotoIds.append(record.id)
importedCount += 1
} catch {
failedPhotoIds.insert(object.id)
@ -212,7 +214,11 @@ final class TravelAlbumCameraImportViewModel {
}
selectedPhotoIds.subtract(existingPhotoIds)
state = .finished(importedCount: importedCount, failedCount: failedPhotoIds.count)
state = .finished(
importedCount: importedCount,
failedCount: failedPhotoIds.count,
importedPhotoIds: importedPhotoIds
)
}
}