Don't unnecessarily retry downloads for expired attachments

pull/461/head
Niels Andriesse 3 years ago
parent 6bc9b21cde
commit 2928a8f66c

@ -1,5 +1,6 @@
import Foundation
import SessionUtilitiesKit
import SessionSnodeKit
import SignalCoreKit
public final class AttachmentDownloadJob : NSObject, Job, NSCoding { // NSObject/NSCoding conformance is needed for YapDatabase compatibility
@ -83,6 +84,10 @@ public final class AttachmentDownloadJob : NSObject, Job, NSCoding { // NSObject
storage.setAttachmentState(to: .failed, for: pointer, associatedWith: self.tsMessageID, using: transaction)
}, completion: { })
self.handlePermanentFailure(error: error)
} else if let error = error as? OnionRequestAPI.Error, case .httpRequestFailedAtDestination(let statusCode, _) = error,
statusCode == 400 {
// This usually indicates a file that has expired on the server, so there's no need to retry.
self.handlePermanentFailure(error: error)
} else {
self.handleFailure(error: error)
}

Loading…
Cancel
Save