Fix ImageCache kicking off extra requests when a completion block was

not provided
This commit is contained in:
Shadowfacts 2021-01-18 13:46:07 -05:00
parent 04a6fe807e
commit de67327f6d
1 changed files with 9 additions and 4 deletions

View File

@ -42,13 +42,18 @@ class ImageCache {
// of the state (unknown/exists/does not exist) of whether or not objects exist on disk so that the slow, disk I/O
// path can be avoided most of the time
let entry = try? cache.get(key) {
if let completion = completion {
backgroundQueue.async {
completion?(entry.data, entry.image)
completion(entry.data, entry.image)
}
}
return nil
} else {
if let completion = completion, let group = groups[url] {
if let group = groups[url] {
if let completion = completion {
return group.addCallback(completion)
}
return nil
} else {
let group = RequestGroup(url: url) { (data, image) in
if let data = data {