|
|
@@ -209,6 +209,22 @@ public class KingfisherManager {
|
|
|
completionHandler?(image, error, cacheType, imageURL)
|
|
|
}
|
|
|
|
|
|
+ func handleNoCache() {
|
|
|
+ if options.onlyFromCache {
|
|
|
+ let error = NSError(domain: KingfisherErrorDomain, code: KingfisherError.notCached.rawValue, userInfo: nil)
|
|
|
+ diskTaskCompletionHandler(nil, error, .none, url)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ self.downloadAndCacheImage(
|
|
|
+ with: url,
|
|
|
+ forKey: key,
|
|
|
+ retrieveImageTask: retrieveImageTask,
|
|
|
+ progressBlock: progressBlock,
|
|
|
+ completionHandler: diskTaskCompletionHandler,
|
|
|
+ options: options)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
let targetCache = options.targetCache
|
|
|
targetCache.retrieveImage(forKey: key, options: options) { image, cacheType in
|
|
|
if image != nil {
|
|
|
@@ -234,21 +250,5 @@ public class KingfisherManager {
|
|
|
|
|
|
handleNoCache()
|
|
|
}
|
|
|
-
|
|
|
- func handleNoCache() {
|
|
|
- if options.onlyFromCache {
|
|
|
- let error = NSError(domain: KingfisherErrorDomain, code: KingfisherError.notCached.rawValue, userInfo: nil)
|
|
|
- diskTaskCompletionHandler(nil, error, .none, url)
|
|
|
- return
|
|
|
- }
|
|
|
- self.downloadAndCacheImage(
|
|
|
- with: url,
|
|
|
- forKey: key,
|
|
|
- retrieveImageTask: retrieveImageTask,
|
|
|
- progressBlock: progressBlock,
|
|
|
- completionHandler: diskTaskCompletionHandler,
|
|
|
- options: options)
|
|
|
-
|
|
|
- }
|
|
|
}
|
|
|
}
|