From 568243100dc9d1f4b583ec98056dd73737ac6748 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 23 Oct 2024 13:56:30 +0800 Subject: [PATCH] Store reachability of FileProviderExt by respective account Signed-off-by: Claudio Cambra --- src/gui/macOS/fileproviderxpc.h | 2 +- src/gui/macOS/fileproviderxpc_mac.mm | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gui/macOS/fileproviderxpc.h b/src/gui/macOS/fileproviderxpc.h index 737657cbaf3d6..349dfc3264034 100644 --- a/src/gui/macOS/fileproviderxpc.h +++ b/src/gui/macOS/fileproviderxpc.h @@ -54,7 +54,7 @@ private slots: private: QHash _clientCommServices; - QDateTime _lastUnreachableTime; + QHash _unreachableAccountExtensions; }; } // namespace OCC::Mac diff --git a/src/gui/macOS/fileproviderxpc_mac.mm b/src/gui/macOS/fileproviderxpc_mac.mm index b2d1793ce5b70..4c55cc5d34490 100644 --- a/src/gui/macOS/fileproviderxpc_mac.mm +++ b/src/gui/macOS/fileproviderxpc_mac.mm @@ -146,7 +146,8 @@ bool FileProviderXPC::fileProviderExtReachable(const QString &extensionAccountId) { - if (_lastUnreachableTime.isValid() && _lastUnreachableTime.secsTo(QDateTime::currentDateTime()) < ::reachableRetryTimeout) { + const auto lastUnreachableTime = _unreachableAccountExtensions.value(extensionAccountId); + if (lastUnreachableTime.isValid() && lastUnreachableTime.secsTo(QDateTime::currentDateTime()) < ::reachableRetryTimeout) { qCInfo(lcFileProviderXPC) << "File provider extension was unreachable less than a minute ago. " << "Not checking again"; return false; @@ -165,9 +166,11 @@ }]; dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, semaphoreWaitDelta)); - if (!response) { + if (response) { + _unreachableAccountExtensions.remove(extensionAccountId); + } else { qCWarning(lcFileProviderXPC) << "Could not reach file provider extension."; - _lastUnreachableTime = QDateTime::currentDateTime(); + _unreachableAccountExtensions.insert(extensionAccountId, QDateTime::currentDateTime()); } return response; }