Move active folder size limit check to independent convenience method

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-06-27 22:09:16 +08:00
parent 17de46cec2
commit e5f399ff51
No known key found for this signature in database
GPG key ID: C839200C384636B0
2 changed files with 13 additions and 4 deletions

View file

@ -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<void(bool)> 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);

View file

@ -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<void(bool)> callback);