mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.2 KiB
Swift
34 lines
1.2 KiB
Swift
3 years ago
|
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
||
|
|
||
|
import Foundation
|
||
|
import GRDB
|
||
|
import SignalCoreKit
|
||
|
import SessionUtilitiesKit
|
||
|
|
||
|
public enum FailedAttachmentDownloadsJob: JobExecutor {
|
||
3 years ago
|
public static let maxFailureCount: Int = -1
|
||
3 years ago
|
public static let requiresThreadId: Bool = false
|
||
3 years ago
|
public static let requiresInteractionId: Bool = false
|
||
3 years ago
|
|
||
|
public static func run(
|
||
|
_ job: Job,
|
||
3 years ago
|
queue: DispatchQueue,
|
||
2 years ago
|
success: @escaping (Job, Bool, Dependencies) -> (),
|
||
|
failure: @escaping (Job, Error?, Bool, Dependencies) -> (),
|
||
|
deferred: @escaping (Job, Dependencies) -> (),
|
||
2 years ago
|
using dependencies: Dependencies
|
||
3 years ago
|
) {
|
||
2 years ago
|
var changeCount: Int = -1
|
||
|
|
||
3 years ago
|
// Update all 'sending' message states to 'failed'
|
||
2 years ago
|
dependencies[singleton: .storage].write { db in
|
||
2 years ago
|
changeCount = try Attachment
|
||
3 years ago
|
.filter(Attachment.Columns.state == Attachment.State.downloading)
|
||
3 years ago
|
.updateAll(db, Attachment.Columns.state.set(to: Attachment.State.failedDownload))
|
||
3 years ago
|
}
|
||
|
|
||
2 years ago
|
SNLog("[FailedAttachmentDownloadsJob] Marked \(changeCount) attachments as failed")
|
||
2 years ago
|
success(job, false, dependencies)
|
||
3 years ago
|
}
|
||
|
}
|