From 57339ab1662eaf913f0258d6debe30bf02aac4da Mon Sep 17 00:00:00 2001 From: Phil Larson Date: Fri, 14 Apr 2017 14:34:18 -0700 Subject: [PATCH] Allow creating a ASPINRemoteImageDownloader that ignores caches --- Source/Details/ASPINRemoteImageDownloader.h | 5 +++++ Source/Details/ASPINRemoteImageDownloader.m | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/Details/ASPINRemoteImageDownloader.h b/Source/Details/ASPINRemoteImageDownloader.h index 268a5ff4e..45b98d9d4 100644 --- a/Source/Details/ASPINRemoteImageDownloader.h +++ b/Source/Details/ASPINRemoteImageDownloader.h @@ -53,6 +53,11 @@ NS_ASSUME_NONNULL_BEGIN */ - (PINRemoteImageManager *)sharedPINRemoteImageManager; +/** + * When downloading images ignore all caches. Defaults to NO. + */ +@property (nonatomic, assign) BOOL shouldIgnoreCache; + @end NS_ASSUME_NONNULL_END diff --git a/Source/Details/ASPINRemoteImageDownloader.m b/Source/Details/ASPINRemoteImageDownloader.m index b861c3055..70e856e16 100644 --- a/Source/Details/ASPINRemoteImageDownloader.m +++ b/Source/Details/ASPINRemoteImageDownloader.m @@ -205,7 +205,13 @@ - (nullable id)downloadImageWithURL:(NSURL *)URL downloadProgress:(ASImageDownloaderProgress)downloadProgress completion:(ASImageDownloaderCompletion)completion; { - return [[self sharedPINRemoteImageManager] downloadImageWithURL:URL options:PINRemoteImageManagerDownloadOptionsSkipDecode progressDownload:^(int64_t completedBytes, int64_t totalBytes) { + PINRemoteImageManagerDownloadOptions options = PINRemoteImageManagerDownloadOptionsSkipDecode; + + if (_shouldIgnoreCache) { + options |= PINRemoteImageManagerDownloadOptionsIgnoreCache; + } + + return [[self sharedPINRemoteImageManager] downloadImageWithURL:URL options:options progressDownload:^(int64_t completedBytes, int64_t totalBytes) { if (downloadProgress == nil) { return; } /// If we're targeting the main queue and we're on the main thread, call immediately.