Skip to content

Commit

Permalink
Store reachability of FileProviderExt by respective account
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Oct 23, 2024
1 parent 532201a commit 5682431
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/gui/macOS/fileproviderxpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private slots:

private:
QHash<QString, void*> _clientCommServices;
QDateTime _lastUnreachableTime;
QHash<QString, QDateTime> _unreachableAccountExtensions;
};

} // namespace OCC::Mac
9 changes: 6 additions & 3 deletions src/gui/macOS/fileproviderxpc_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit 5682431

Please sign in to comment.