Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #2375: Crash when NTP resource is downloaded with network error.
Browse files Browse the repository at this point in the history
  • Loading branch information
iccub committed Feb 27, 2020
1 parent 2003a04 commit 777fc1b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Client/Frontend/Browser/HomePanel/NTPDownloader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,18 @@ class NTPDownloader {
guard let self = self else { return }

if let error = error {
return completion(nil, nil, error)
completion(nil, nil, error)
return
}

guard let response = response as? HTTPURLResponse else {
return completion(nil, nil, "Response is not an HTTP Response")
completion(nil, nil, "Response is not an HTTP Response")
return
}

if response.statusCode != 304 && (response.statusCode < 200 || response.statusCode > 299) {
completion(nil, nil, "Invalid Response Status Code: \(response.statusCode)")
return
}

completion(data, self.parseETagResponseInfo(response), nil)
Expand Down Expand Up @@ -356,12 +359,14 @@ class NTPDownloader {
self.download(path: itemURL, etag: nil) { data, _, err in
if let err = err {
error = err
return group.leave()
group.leave()
return
}

guard let data = data else {
error = "No Data Available for NTP-Download: \(itemURL)"
return group.leave()
group.leave()
return
}

do {
Expand Down

0 comments on commit 777fc1b

Please # to comment.