Don't retry attachment downloads if the response was invalid

This commit is contained in:
nielsandriesse 2020-12-02 10:01:34 +11:00
parent 5ccf25181c
commit e21e703581
1 changed files with 7 additions and 0 deletions

View File

@ -64,6 +64,13 @@ public final class AttachmentDownloadJob : NSObject, Job, NSCoding { // NSObject
storage.setAttachmentState(to: .failed, for: pointer, associatedWith: self.tsIncomingMessageID, using: transaction)
}, completion: { })
self.handlePermanentFailure(error: error)
} else if let error = error as? DotNetAPI.Error, case .parsingFailed = error {
// No need to retry if the response is invalid. Most likely this means we (incorrectly)
// got a "Cannot GET ..." error from the file server.
storage.withAsync({ transaction in
storage.setAttachmentState(to: .failed, for: pointer, associatedWith: self.tsIncomingMessageID, using: transaction)
}, completion: { })
self.handlePermanentFailure(error: error)
} else {
self.handleFailure(error: error)
}