forked from shadowfacts/Tusker
Fix ImageCache kicking off extra requests when a completion block was
not provided
This commit is contained in:
parent
04a6fe807e
commit
de67327f6d
|
@ -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
|
// 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
|
// path can be avoided most of the time
|
||||||
let entry = try? cache.get(key) {
|
let entry = try? cache.get(key) {
|
||||||
backgroundQueue.async {
|
if let completion = completion {
|
||||||
completion?(entry.data, entry.image)
|
backgroundQueue.async {
|
||||||
|
completion(entry.data, entry.image)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
if let completion = completion, let group = groups[url] {
|
if let group = groups[url] {
|
||||||
return group.addCallback(completion)
|
if let completion = completion {
|
||||||
|
return group.addCallback(completion)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
} else {
|
} else {
|
||||||
let group = RequestGroup(url: url) { (data, image) in
|
let group = RequestGroup(url: url) { (data, image) in
|
||||||
if let data = data {
|
if let data = data {
|
||||||
|
|
Loading…
Reference in New Issue