mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-29 00:31:14 +00:00
Release a URL's download callbacks before calling them, so a callback that starts a new download of the same URL isn't silently dropped.
This commit is contained in:
1 parent
e2fe6a1798
commit
056fa5ff76
1 file changed
+3
-4
@@ -133,16 +133,15 @@ private extension Downloader {
|
||||
func callAndReleaseCallbacks(_ url: URL, _ data: Data? = nil, _ response: URLResponse? = nil, _ error: Error? = nil) {
|
||||
assert(Thread.isMainThread)
|
||||
|
||||
defer {
|
||||
callbacks[url] = nil
|
||||
}
|
||||
|
||||
guard let callbacksForURL = callbacks[url] else {
|
||||
assertionFailure("Downloader: downloaded URL \(url) but no callbacks found")
|
||||
Self.logger.fault("Downloader: downloaded URL \(url) but no callbacks found")
|
||||
return
|
||||
}
|
||||
|
||||
// Release before calling — a callback may start a new download of the same URL.
|
||||
callbacks[url] = nil
|
||||
|
||||
let count = callbacksForURL.count
|
||||
if count == 1 {
|
||||
Self.logger.debug("Downloader: calling 1 callback for URL \(url)")
|
||||
|
||||
Reference in new issue
Block a user