Skip to content

Commit e2ec80e

Browse files
committed
fix(#195): Handle zero-byte downloads correctly.
When downloading zero byte files previously, the responseData handler raises an error while the plain response handler meant for file downloads does not. Signed-off-by: Iva Horn <iva.horn@nextcloud.com>
1 parent 1f63a5a commit e2ec80e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Sources/NextcloudKit/NextcloudKit+Download.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,11 @@ public extension NextcloudKit {
5050
options.queue.async { taskHandler(task) }
5151
} .downloadProgress { progress in
5252
options.queue.async { progressHandler(progress) }
53-
} .responseData(queue: self.nkCommonInstance.backgroundQueue) { response in
54-
switch response.result {
55-
case .failure(let error):
53+
} .response(queue: self.nkCommonInstance.backgroundQueue) { response in
54+
if let error = response.error {
5655
let resultError = NKError(error: error, afResponse: response, responseData: nil)
5756
options.queue.async { completionHandler(account, nil, nil, 0, response.response?.allHeaderFields, error, resultError) }
58-
case .success:
57+
} else {
5958
var date: Date?
6059
var etag: String?
6160
var length: Int64 = 0

0 commit comments

Comments
 (0)