From 314d47e74d7cf6122b01763bfd142a597308557f Mon Sep 17 00:00:00 2001 From: Iva Horn Date: Wed, 15 Oct 2025 15:52:25 +0200 Subject: [PATCH] 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 --- Sources/NextcloudKit/NextcloudKit+Download.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Sources/NextcloudKit/NextcloudKit+Download.swift b/Sources/NextcloudKit/NextcloudKit+Download.swift index 0a3f9972..9679b06f 100644 --- a/Sources/NextcloudKit/NextcloudKit+Download.swift +++ b/Sources/NextcloudKit/NextcloudKit+Download.swift @@ -50,12 +50,11 @@ public extension NextcloudKit { options.queue.async { taskHandler(task) } } .downloadProgress { progress in options.queue.async { progressHandler(progress) } - } .responseData(queue: self.nkCommonInstance.backgroundQueue) { response in - switch response.result { - case .failure(let error): + } .response(queue: self.nkCommonInstance.backgroundQueue) { response in + if let error = response.error { let resultError = NKError(error: error, afResponse: response, responseData: nil) options.queue.async { completionHandler(account, nil, nil, 0, response.response?.allHeaderFields, error, resultError) } - case .success: + } else { var date: Date? var etag: String? var length: Int64 = 0