From 4d7b3eeacb34f811280e57c5d71b5acd5c6a1b0b Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 30 Sep 2024 16:05:30 +0800 Subject: [PATCH] Handle userId correctly in File Provider Extension client interface Signed-off-by: Claudio Cambra --- .../FileProviderExtension+ClientInterface.swift | 10 ++++++---- .../FileProviderSocketLineProcessor.swift | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension+ClientInterface.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension+ClientInterface.swift index 878569945..99eaefb50 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension+ClientInterface.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension+ClientInterface.swift @@ -104,12 +104,14 @@ extension FileProviderExtension: NSFileProviderServicing, ChangeNotificationInte } } - @objc func setupDomainAccount(user: String, serverUrl: String, password: String) { + @objc func setupDomainAccount( + user: String, userId: String, serverUrl: String, password: String + ) { let semaphore = DispatchSemaphore(value: 0) var authAttemptState = AuthenticationAttemptResultState.connectionError // default Task { let authTestNcKit = NextcloudKit() - authTestNcKit.setup(user: user, userId: user, password: password, urlBase: serverUrl) + authTestNcKit.setup(user: user, userId: userId, password: password, urlBase: serverUrl) // Retry a few times if we have a connection issue for authTimeout in AuthenticationTimeouts { @@ -146,13 +148,13 @@ extension FileProviderExtension: NSFileProviderServicing, ChangeNotificationInte ) } - let newNcAccount = Account(user: user, serverUrl: serverUrl, password: password) + let newNcAccount = Account(user: user, id: userId, serverUrl: serverUrl, password: password) guard newNcAccount != ncAccount else { return } ncAccount = newNcAccount ncKit.setup( account: newNcAccount.ncKitAccount, user: newNcAccount.username, - userId: newNcAccount.username, + userId: newNcAccount.id, password: newNcAccount.password, urlBase: newNcAccount.serverUrl, userAgent: "Nextcloud-macOS/FileProviderExt", diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderSocketLineProcessor.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderSocketLineProcessor.swift index ebc4bc4b9..c9a49d419 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderSocketLineProcessor.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderSocketLineProcessor.swift @@ -53,7 +53,7 @@ class FileProviderSocketLineProcessor: NSObject, LineProcessor { let serverUrl = String(splitAccountDetails[2]) let password = String(splitAccountDetails[3]) - delegate.setupDomainAccount(user: user, serverUrl: serverUrl, password: password) + delegate.setupDomainAccount(user: user, userId: userId, serverUrl: serverUrl, password: password) } } }