Don't unnecessarily retry downloads for expired attachments
This commit is contained in:
parent
6bc9b21cde
commit
2928a8f66c
|
@ -1,5 +1,6 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
import SessionUtilitiesKit
|
import SessionUtilitiesKit
|
||||||
|
import SessionSnodeKit
|
||||||
import SignalCoreKit
|
import SignalCoreKit
|
||||||
|
|
||||||
public final class AttachmentDownloadJob : NSObject, Job, NSCoding { // NSObject/NSCoding conformance is needed for YapDatabase compatibility
|
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)
|
storage.setAttachmentState(to: .failed, for: pointer, associatedWith: self.tsMessageID, using: transaction)
|
||||||
}, completion: { })
|
}, completion: { })
|
||||||
self.handlePermanentFailure(error: error)
|
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 {
|
} else {
|
||||||
self.handleFailure(error: error)
|
self.handleFailure(error: error)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue