修复 OTG 列表删除照片后边拍边传仍会带回已删项的问题。
删除时同步清理管道任务并维护 excludedAssetIDs,避免 notify 将无本地文件的旧任务重新展示为仅文件名的待上传项。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -27,6 +27,8 @@ final class CameraTransferPipeline {
|
||||
private let deferredNotifyInterval: TimeInterval = 0.15
|
||||
private let maxConcurrentUploads = 3
|
||||
private var isUIAttached = false
|
||||
/// 用户已从列表删除、不应再同步或展示的 asset ID。
|
||||
private(set) var excludedAssetIDs: Set<String> = []
|
||||
|
||||
/// 初始化传输管道,并注入相机服务。
|
||||
init(cameraService: any CameraServiceProtocol) {
|
||||
@ -224,7 +226,24 @@ final class CameraTransferPipeline {
|
||||
tasks.first { $0.assetID == assetID }
|
||||
}
|
||||
|
||||
/// 同步用户已删除的 asset ID,防止 sync/notify 再次带回。
|
||||
func setExcludedAssetIDs(_ ids: Set<String>) {
|
||||
excludedAssetIDs = ids
|
||||
}
|
||||
|
||||
/// 从管道移除 asset,并阻止后续自动同步。
|
||||
func removeAsset(assetID: String) {
|
||||
guard !assetID.isEmpty else { return }
|
||||
excludedAssetIDs.insert(assetID)
|
||||
tasks.removeAll { $0.assetID == assetID }
|
||||
autoUploadEligibleAssetIDs.remove(assetID)
|
||||
activeUploadAssetIDs.remove(assetID)
|
||||
inFlightAssetIDs.remove(assetID)
|
||||
lastNotifiedProgressByAssetID.removeValue(forKey: assetID)
|
||||
}
|
||||
|
||||
private func handleNewAsset(_ asset: CameraAsset, skipIfExists: Bool) async {
|
||||
if excludedAssetIDs.contains(asset.id) { return }
|
||||
if skipIfExists,
|
||||
let existing = tasks.first(where: { $0.assetID == asset.id }),
|
||||
existing.status == .uploaded || existing.status == .downloaded {
|
||||
|
||||
Reference in New Issue
Block a user