Jelajahi Sumber

Merge pull request #701 from arkth-araya/fix/issue700

 #700 Fix 'handleNoCache' before its declaration
Wei Wang 8 tahun lalu
induk
melakukan
339acb43fe
1 mengubah file dengan 16 tambahan dan 16 penghapusan
  1. 16 16
      Sources/KingfisherManager.swift

+ 16 - 16
Sources/KingfisherManager.swift

@@ -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)
-            
-        }
     }
 }