From: Claudio Cambra Date: Tue, 5 Nov 2024 07:05:33 +0000 (+0900) Subject: If fileProviderExtRecheable is false, try to reconfigure client communication service X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~58^2^2~43^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=43ea9b6d833bd3961e3bf3093a8438e83e4795ae;p=nextcloud-desktop.git If fileProviderExtRecheable is false, try to reconfigure client communication service Signed-off-by: Claudio Cambra --- diff --git a/src/gui/macOS/fileproviderxpc.h b/src/gui/macOS/fileproviderxpc.h index 349dfc326..39bc86397 100644 --- a/src/gui/macOS/fileproviderxpc.h +++ b/src/gui/macOS/fileproviderxpc.h @@ -35,7 +35,7 @@ class FileProviderXPC : public QObject public: explicit FileProviderXPC(QObject *parent = nullptr); - [[nodiscard]] bool fileProviderExtReachable(const QString &extensionAccountId); + [[nodiscard]] bool fileProviderExtReachable(const QString &extensionAccountId, bool retry = true, bool reconfigureOnFail = true); // Returns enabled and set state of fast enumeration for the given extension [[nodiscard]] std::optional> fastEnumerationStateForExtension(const QString &extensionAccountId) const; diff --git a/src/gui/macOS/fileproviderxpc_mac.mm b/src/gui/macOS/fileproviderxpc_mac.mm index 4c55cc5d3..96877d368 100644 --- a/src/gui/macOS/fileproviderxpc_mac.mm +++ b/src/gui/macOS/fileproviderxpc_mac.mm @@ -17,6 +17,7 @@ #include #include "gui/accountmanager.h" +#include "gui/macOS/fileprovider.h" #include "gui/macOS/fileproviderdomainmanager.h" #include "gui/macOS/fileproviderxpc_mac_utils.h" @@ -144,10 +145,12 @@ void FileProviderXPC::createDebugArchiveForExtension(const QString &extensionAcc } } -bool FileProviderXPC::fileProviderExtReachable(const QString &extensionAccountId) -{ +bool FileProviderXPC::fileProviderExtReachable(const QString &extensionAccountId, const bool retry, const bool reconfigureOnFail) const auto lastUnreachableTime = _unreachableAccountExtensions.value(extensionAccountId); - if (lastUnreachableTime.isValid() && lastUnreachableTime.secsTo(QDateTime::currentDateTime()) < ::reachableRetryTimeout) { + if (!retry + && !reconfigureOnFail + && lastUnreachableTime.isValid() + && lastUnreachableTime.secsTo(QDateTime::currentDateTime()) < ::reachableRetryTimeout) { qCInfo(lcFileProviderXPC) << "File provider extension was unreachable less than a minute ago. " << "Not checking again"; return false; @@ -155,6 +158,7 @@ bool FileProviderXPC::fileProviderExtReachable(const QString &extensionAccountId const auto service = (NSObject *)_clientCommServices.value(extensionAccountId); if (service == nil) { + qCWarning(lcFileProviderXPC) << "Could not get service for extension" << extensionAccountId; return false; } @@ -170,7 +174,27 @@ bool FileProviderXPC::fileProviderExtReachable(const QString &extensionAccountId _unreachableAccountExtensions.remove(extensionAccountId); } else { qCWarning(lcFileProviderXPC) << "Could not reach file provider extension."; - _unreachableAccountExtensions.insert(extensionAccountId, QDateTime::currentDateTime()); + + if (reconfigureOnFail) { + qCWarning(lcFileProviderXPC) << "Could not reach extension" + << extensionAccountId + << "going to attempt reconfiguring interface"; + const auto ncDomainManager = FileProvider::instance()->domainManager(); + const auto accountState = ncDomainManager->accountStateFromFileProviderDomainIdentifier(extensionAccountId); + const auto domain = (NSFileProviderDomain *)(ncDomainManager->domainForAccount(accountState.get())); + const auto manager = [NSFileProviderManager managerForDomain:domain]; + const auto fpServices = FileProviderXPCUtils::getFileProviderServices(@[manager]); + const auto connections = FileProviderXPCUtils::connectToFileProviderServices(fpServices); + const auto services = FileProviderXPCUtils::processClientCommunicationConnections(connections); + _clientCommServices.insert(services); + } + + if (retry) { + qCWarning(lcFileProviderXPC) << "Could not reach extension" << extensionAccountId << "retrying"; + return fileProviderExtReachable(extensionAccountId, false, false); + } else { + _unreachableAccountExtensions.insert(extensionAccountId, QDateTime::currentDateTime()); + } } return response; }