mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-21 20:45:51 +03:00
Merge pull request #7397 from nextcloud/bugfix/mac-vfs-syncstatechange-freeze
Fix stuttering and freezing of client while computing sync state changes (macOS VFS)
This commit is contained in:
commit
01da699e7a
2 changed files with 21 additions and 3 deletions
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
#include <QDateTime>
|
||||
|
||||
#include "accountstate.h"
|
||||
|
||||
|
@ -34,7 +35,7 @@ class FileProviderXPC : public QObject
|
|||
public:
|
||||
explicit FileProviderXPC(QObject *parent = nullptr);
|
||||
|
||||
[[nodiscard]] bool fileProviderExtReachable(const QString &extensionAccountId) const;
|
||||
[[nodiscard]] bool fileProviderExtReachable(const QString &extensionAccountId);
|
||||
|
||||
// Returns enabled and set state of fast enumeration for the given extension
|
||||
[[nodiscard]] std::optional<std::pair<bool, bool>> fastEnumerationStateForExtension(const QString &extensionAccountId) const;
|
||||
|
@ -53,6 +54,7 @@ private slots:
|
|||
|
||||
private:
|
||||
QHash<QString, void*> _clientCommServices;
|
||||
QHash<QString, QDateTime> _unreachableAccountExtensions;
|
||||
};
|
||||
|
||||
} // namespace OCC::Mac
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
#include "gui/macOS/fileproviderxpc_mac_utils.h"
|
||||
|
||||
namespace {
|
||||
constexpr int64_t semaphoreWaitDelta = 3000000000; // 3 seconds
|
||||
constexpr int64_t semaphoreWaitDelta = 1000000000; // 1 seconds
|
||||
constexpr auto reachableRetryTimeout = 300; // seconds
|
||||
}
|
||||
|
||||
namespace OCC::Mac {
|
||||
|
@ -143,12 +144,20 @@ void FileProviderXPC::createDebugArchiveForExtension(const QString &extensionAcc
|
|||
}
|
||||
}
|
||||
|
||||
bool FileProviderXPC::fileProviderExtReachable(const QString &extensionAccountId) const
|
||||
bool FileProviderXPC::fileProviderExtReachable(const QString &extensionAccountId)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
const auto service = (NSObject<ClientCommunicationProtocol> *)_clientCommServices.value(extensionAccountId);
|
||||
if (service == nil) {
|
||||
return false;
|
||||
}
|
||||
|
||||
__block auto response = false;
|
||||
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
||||
[service getExtensionAccountIdWithCompletionHandler:^(NSString *const, NSError *const) {
|
||||
|
@ -156,6 +165,13 @@ bool FileProviderXPC::fileProviderExtReachable(const QString &extensionAccountId
|
|||
dispatch_semaphore_signal(semaphore);
|
||||
}];
|
||||
dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, semaphoreWaitDelta));
|
||||
|
||||
if (response) {
|
||||
_unreachableAccountExtensions.remove(extensionAccountId);
|
||||
} else {
|
||||
qCWarning(lcFileProviderXPC) << "Could not reach file provider extension.";
|
||||
_unreachableAccountExtensions.insert(extensionAccountId, QDateTime::currentDateTime());
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue