From e5f399ff51fa101939220b7fa88bfa8c67d106cd Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 27 Jun 2023 22:09:16 +0800 Subject: [PATCH] Move active folder size limit check to independent convenience method Signed-off-by: Claudio Cambra --- src/libsync/discoveryphase.cpp | 15 +++++++++++---- src/libsync/discoveryphase.h | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/libsync/discoveryphase.cpp b/src/libsync/discoveryphase.cpp index 3fef366c5..05ab70266 100644 --- a/src/libsync/discoveryphase.cpp +++ b/src/libsync/discoveryphase.cpp @@ -82,11 +82,15 @@ bool DiscoveryPhase::isInSelectiveSyncBlackList(const QString &path) const return false; } +bool DiscoveryPhase::activeFolderSizeLimit() const +{ + return _syncOptions._newBigFolderSizeLimit > 0 && _syncOptions._vfs->mode() == Vfs::Off; +} + void DiscoveryPhase::checkFolderSizeLimit(const QString &path, const std::function callback) { - const auto limit = _syncOptions._newBigFolderSizeLimit; - if (limit < 0 || _syncOptions._vfs->mode() != Vfs::Off) { + if (activeFolderSizeLimit()) { // no limit, everything is allowed; return callback(false); } @@ -98,8 +102,11 @@ void DiscoveryPhase::checkFolderSizeLimit(const QString &path, connect(propfindJob, &PropfindJob::finishedWithError, this, [=] { return callback(false); }); connect(propfindJob, &PropfindJob::result, this, [=](const QVariantMap &values) { - auto result = values.value(QLatin1String("size")).toLongLong(); - if (result >= limit) { + + if (const auto result = values.value(QLatin1String("size")).toLongLong(), + limit = _syncOptions._newBigFolderSizeLimit; + result >= limit) { + // we tell the UI there is a new folder emit newBigFolder(path, false); return callback(true); diff --git a/src/libsync/discoveryphase.h b/src/libsync/discoveryphase.h index 948500371..93f398922 100644 --- a/src/libsync/discoveryphase.h +++ b/src/libsync/discoveryphase.h @@ -255,6 +255,8 @@ class DiscoveryPhase : public QObject [[nodiscard]] bool isInSelectiveSyncBlackList(const QString &path) const; + [[nodiscard]] bool activeFolderSizeLimit() const; + void checkFolderSizeLimit(const QString &path, const std::function callback);