From 4935d1f8debf95d1b05fdead401c28cc9e008e68 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 30 Jan 2024 13:38:55 +0800 Subject: [PATCH] Do not reconfigure file provider extension account if we are receiving the same details again Signed-off-by: Claudio Cambra --- .../FileProviderExtension+ClientInterface.swift | 6 ++++-- .../FileProviderExt/NextcloudAccount.swift | 4 +--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension+ClientInterface.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension+ClientInterface.swift index aebb6ab012b62..a357b79eae20a 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension+ClientInterface.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/FileProviderExtension+ClientInterface.swift @@ -88,7 +88,9 @@ extension FileProviderExtension: NSFileProviderServicing { } @objc func setupDomainAccount(user: String, serverUrl: String, password: String) { - ncAccount = NextcloudAccount(user: user, serverUrl: serverUrl, password: password) + let newNcAccount = NextcloudAccount(user: user, serverUrl: serverUrl, password: password) + guard newNcAccount != ncAccount else { return } + ncAccount = newNcAccount ncKit.setup( user: ncAccount!.username, userId: ncAccount!.username, @@ -96,7 +98,7 @@ extension FileProviderExtension: NSFileProviderServicing { urlBase: ncAccount!.serverUrl, userAgent: "Nextcloud-macOS/FileProviderExt", nextcloudVersion: 25, - delegate: nil) // TODO: add delegate methods for self + delegate: nil) // TODO: add delegate methods for self Logger.fileProviderExtension.info( "Nextcloud account set up in File Provider extension for user: \(user, privacy: .public) at server: \(serverUrl, privacy: .public)" diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudAccount.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudAccount.swift index 9e5b64656608d..cb3b7ea628f9c 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudAccount.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderExt/NextcloudAccount.swift @@ -15,7 +15,7 @@ import FileProvider import Foundation -class NextcloudAccount: NSObject { +struct NextcloudAccount: Equatable { static let webDavFilesUrlSuffix: String = "/remote.php/dav/files/" let username, password, ncKitAccount, serverUrl, davFilesUrl: String @@ -25,7 +25,5 @@ class NextcloudAccount: NSObject { ncKitAccount = user + " " + serverUrl self.serverUrl = serverUrl davFilesUrl = serverUrl + NextcloudAccount.webDavFilesUrlSuffix + user - - super.init() } }