mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-02 02:22:25 +00:00
Add notAttempted error.
This commit is contained in:
1 parent
0956cbabd3
commit
ae87e309dd
2 files changed
+7
-4
No files matched your search
@@ -209,21 +209,21 @@ private extension DownloadedImageCache {
|
||||
}
|
||||
|
||||
if isWaitingToRetry(url) {
|
||||
return .failure(ImageDownloadError(statusCode: nil, decodingFailed: false, isTransient: true))
|
||||
return .failure(.notAttempted)
|
||||
}
|
||||
let host = Self.host(url)
|
||||
if usesDownloadQueue {
|
||||
guard Self.networkAllowsDownloads else {
|
||||
return .failure(ImageDownloadError(statusCode: nil, decodingFailed: false, isTransient: true))
|
||||
return .failure(.notAttempted)
|
||||
}
|
||||
switch await downloadQueue.waitForTurn(key: url, group: host) {
|
||||
case .dropped:
|
||||
return .failure(ImageDownloadError(statusCode: nil, decodingFailed: false, isTransient: true))
|
||||
return .failure(.notAttempted)
|
||||
case .start:
|
||||
// The network or a retry wait may have changed while this was queued.
|
||||
guard !isWaitingToRetry(url), Self.networkAllowsDownloads else {
|
||||
downloadQueue.taskDidFinish(group: host)
|
||||
return .failure(ImageDownloadError(statusCode: nil, decodingFailed: false, isTransient: true))
|
||||
return .failure(.notAttempted)
|
||||
}
|
||||
case .startNow:
|
||||
break
|
||||
|
||||
@@ -15,6 +15,9 @@ public struct ImageDownloadError: Error {
|
||||
public let retryAfter: TimeInterval? // From a Retry-After header in seconds
|
||||
public let rejectedByteCount: Int? // Too large to save for the timeline
|
||||
|
||||
/// No request was made: waiting to retry, dropped from the download queue, or the network doesn’t allow the download.
|
||||
static let notAttempted = ImageDownloadError(statusCode: nil, decodingFailed: false, isTransient: true)
|
||||
|
||||
init(statusCode: Int?, decodingFailed: Bool, isTransient: Bool, rejectedPixelSize: (width: Int, height: Int)? = nil, retryAfter: TimeInterval? = nil, rejectedByteCount: Int? = nil) {
|
||||
self.statusCode = statusCode
|
||||
self.decodingFailed = decodingFailed
|
||||
|
||||
Reference in new issue
Block a user