From 2928a8f66c72df2d1cdad0f9513fda18b43dd646 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Tue, 13 Jul 2021 09:46:27 +1000 Subject: [PATCH] Don't unnecessarily retry downloads for expired attachments --- SessionMessagingKit/Jobs/AttachmentDownloadJob.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SessionMessagingKit/Jobs/AttachmentDownloadJob.swift b/SessionMessagingKit/Jobs/AttachmentDownloadJob.swift index b5eb03556..872ec24d8 100644 --- a/SessionMessagingKit/Jobs/AttachmentDownloadJob.swift +++ b/SessionMessagingKit/Jobs/AttachmentDownloadJob.swift @@ -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) }