From 84af6ecb330e67e2a56cc0eedcdcdab66c034ccc Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Tue, 24 Jun 2025 16:25:11 +0200 Subject: [PATCH 1/3] async wrapper Signed-off-by: Marino Faggiana --- Sources/NextcloudKit/NextcloudKit+E2EE.swift | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Sources/NextcloudKit/NextcloudKit+E2EE.swift b/Sources/NextcloudKit/NextcloudKit+E2EE.swift index 28640a69..ba1a3db0 100644 --- a/Sources/NextcloudKit/NextcloudKit+E2EE.swift +++ b/Sources/NextcloudKit/NextcloudKit+E2EE.swift @@ -163,6 +163,29 @@ public extension NextcloudKit { } } + // Async wrapper for getE2EEMetadata + func getE2EEMetadataAsync(fileId: String, + e2eToken: String? = nil, + account: String, + options: NKRequestOptions = NKRequestOptions(), + taskHandler: @escaping (_ task: URLSessionTask) -> Void = { _ in }) async -> Result<(e2eMetadata: String?, signature: String?, responseData: AFDataResponse), NKError> { + await withCheckedContinuation { continuation in + getE2EEMetadata( + fileId: fileId, + e2eToken: e2eToken, + account: account, + options: options, + taskHandler: taskHandler + ) { account, e2eMetadata, signature, responseData, error in + if error == .success { + continuation.resume(returning: .success((e2eMetadata, signature, responseData!))) + } else { + continuation.resume(returning: .failure(error)) + } + } + } + } + func putE2EEMetadata(fileId: String, e2eToken: String, e2eMetadata: String?, From e6d69724316f1fdfeb64254331db9034d60193e1 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Tue, 24 Jun 2025 16:34:44 +0200 Subject: [PATCH 2/3] async Signed-off-by: Marino Faggiana --- Sources/NextcloudKit/NextcloudKit+E2EE.swift | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Sources/NextcloudKit/NextcloudKit+E2EE.swift b/Sources/NextcloudKit/NextcloudKit+E2EE.swift index ba1a3db0..1732d0a8 100644 --- a/Sources/NextcloudKit/NextcloudKit+E2EE.swift +++ b/Sources/NextcloudKit/NextcloudKit+E2EE.swift @@ -168,7 +168,7 @@ public extension NextcloudKit { e2eToken: String? = nil, account: String, options: NKRequestOptions = NKRequestOptions(), - taskHandler: @escaping (_ task: URLSessionTask) -> Void = { _ in }) async -> Result<(e2eMetadata: String?, signature: String?, responseData: AFDataResponse), NKError> { + taskHandler: @escaping (_ task: URLSessionTask) -> Void = { _ in }) async -> (account: String, e2eToken: String?, responseData: AFDataResponse?, error: NKError) { await withCheckedContinuation { continuation in getE2EEMetadata( fileId: fileId, @@ -177,11 +177,7 @@ public extension NextcloudKit { options: options, taskHandler: taskHandler ) { account, e2eMetadata, signature, responseData, error in - if error == .success { - continuation.resume(returning: .success((e2eMetadata, signature, responseData!))) - } else { - continuation.resume(returning: .failure(error)) - } + continuation.resume(returning: (account: account, e2eToken: e2eToken, responseData: responseData, error: error)) } } } From 789cfc518d265f7dca576ad048b356e59ed908fd Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Tue, 24 Jun 2025 16:41:34 +0200 Subject: [PATCH 3/3] fix Signed-off-by: Marino Faggiana --- Sources/NextcloudKit/NextcloudKit+E2EE.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/NextcloudKit/NextcloudKit+E2EE.swift b/Sources/NextcloudKit/NextcloudKit+E2EE.swift index 1732d0a8..ec2eb9af 100644 --- a/Sources/NextcloudKit/NextcloudKit+E2EE.swift +++ b/Sources/NextcloudKit/NextcloudKit+E2EE.swift @@ -168,7 +168,7 @@ public extension NextcloudKit { e2eToken: String? = nil, account: String, options: NKRequestOptions = NKRequestOptions(), - taskHandler: @escaping (_ task: URLSessionTask) -> Void = { _ in }) async -> (account: String, e2eToken: String?, responseData: AFDataResponse?, error: NKError) { + taskHandler: @escaping (_ task: URLSessionTask) -> Void = { _ in }) async -> (account: String, e2eMetadata: String?, signature: String?, responseData: AFDataResponse?, error: NKError) { await withCheckedContinuation { continuation in getE2EEMetadata( fileId: fileId, @@ -177,7 +177,7 @@ public extension NextcloudKit { options: options, taskHandler: taskHandler ) { account, e2eMetadata, signature, responseData, error in - continuation.resume(returning: (account: account, e2eToken: e2eToken, responseData: responseData, error: error)) + continuation.resume(returning: (account: account, e2eMetadata: e2eMetadata, signature: signature, responseData: responseData, error: error)) } } }