Skip to content

Commit

Permalink
Merge pull request onevcat#1351 from onevcat/fix/fromMemoryCacheOrRef…
Browse files Browse the repository at this point in the history
…resh-skip

Make sure to skip disk cache when `fromMemoryCacheOrRefresh` set
  • Loading branch information
onevcat authored Nov 19, 2019
2 parents 9ceea64 + 2d0f6da commit 1bcb180
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Sources/General/KingfisherManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,15 @@ public class KingfisherManager {
}

// Check whether the unprocessed image existing or not.
let originalImageCached = originalCache.imageCachedType(
forKey: key, processorIdentifier: DefaultImageProcessor.default.identifier).cached
if originalImageCached {
let originalImageCacheType = originalCache.imageCachedType(
forKey: key, processorIdentifier: DefaultImageProcessor.default.identifier)
let canAcceptDiskCache = !options.fromMemoryCacheOrRefresh

let canUseOriginalImageCache =
(canAcceptDiskCache && originalImageCacheType.cached) ||
(!canAcceptDiskCache && originalImageCacheType == .memory)

if canUseOriginalImageCache {
// Now we are ready to get found the original image from cache. We need the unprocessed image, so remove
// any processor from options first.
var optionsWithoutProcessor = options
Expand All @@ -509,6 +515,7 @@ public class KingfisherManager {
result.match(
onSuccess: { cacheResult in
guard let image = cacheResult.image else {
assertionFailure("The image (under key: \(key) should be existing in the original cache.")
return
}

Expand Down

0 comments on commit 1bcb180

Please sign in to comment.