Store reachability of FileProviderExt by respective account

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-10-23 13:56:30 +08:00
parent 4ecaed47df
commit c48ecf8d60
2 changed files with 7 additions and 4 deletions

View File

@ -54,7 +54,7 @@ private slots:
private:
QHash<QString, void*> _clientCommServices;
QDateTime _lastUnreachableTime;
QHash<QString, QDateTime> _unreachableAccountExtensions;
};
} // namespace OCC::Mac

View File

@ -146,7 +146,8 @@ void FileProviderXPC::createDebugArchiveForExtension(const QString &extensionAcc
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 @@ bool FileProviderXPC::fileProviderExtReachable(const QString &extensionAccountId
}];
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;
}