From e21e703581e81a5f945064b4f13446ec1c3757fc Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Wed, 2 Dec 2020 10:01:34 +1100 Subject: [PATCH] Don't retry attachment downloads if the response was invalid --- SessionMessagingKit/Jobs/AttachmentDownloadJob.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/SessionMessagingKit/Jobs/AttachmentDownloadJob.swift b/SessionMessagingKit/Jobs/AttachmentDownloadJob.swift index 706e2e353..3b56df75e 100644 --- a/SessionMessagingKit/Jobs/AttachmentDownloadJob.swift +++ b/SessionMessagingKit/Jobs/AttachmentDownloadJob.swift @@ -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) }