Skip to content

Commit

Permalink
Create and connect specific signal for existing folder now being disc…
Browse files Browse the repository at this point in the history
…overed to be big

Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Jun 28, 2023
1 parent fbe5251 commit d61f07e
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/gui/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Folder::Folder(const FolderDefinition &definition,
this, &Folder::slotItemCompleted);
connect(_engine.data(), &SyncEngine::newBigFolder,
this, &Folder::slotNewBigFolderDiscovered);
connect(_engine.data(), &SyncEngine::existingFolderNowBig, this, &Folder::slotExistingFolderNowBig);
connect(_engine.data(), &SyncEngine::seenLockedFile, FolderMan::instance(), &FolderMan::slotSyncOnceFileUnlocks);
connect(_engine.data(), &SyncEngine::aboutToPropagate,
this, &Folder::slotLogPropagationStart);
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo(const SyncFileItemPtr &it
ENFORCE(dbEntry.isDirectory());

if (differingSize) {
_discoveryData->checkSelectiveSyncExistingFolder(path._server, serverEntry.remotePerm, sizeOnServer);
_discoveryData->checkSelectiveSyncExistingFolder(path._server, sizeOnServer);
}

item->_instruction = CSYNC_INSTRUCTION_UPDATE_METADATA;
Expand Down
6 changes: 2 additions & 4 deletions src/libsync/discoveryphase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,14 @@ void DiscoveryPhase::checkSelectiveSyncNewFolder(const QString &path,
checkFolderSizeLimit(path, callback);
}

void DiscoveryPhase::checkSelectiveSyncExistingFolder(const QString &path, const RemotePermissions &rp, const qint64 folderSize)
void DiscoveryPhase::checkSelectiveSyncExistingFolder(const QString &path, const qint64 folderSize)
{
// TODO: Check for setting to obey big folder sync
// If no size limit is enforced, or if is in whitelist (explicitly allowed) or in blacklist (explicitly disallowed), do nothing.
if (!activeFolderSizeLimit() || findPathInList(_selectiveSyncWhiteList, path) || findPathInList(_selectiveSyncBlackList, path)) {
return;
} else if (folderSize >= _syncOptions._newBigFolderSizeLimit) { // If the folder is too big, notify the user and prompt for response.
const auto isExternalStorage =
_syncOptions._confirmExternalStorage && _syncOptions._vfs->mode() == Vfs::Off && rp.hasPermission(RemotePermissions::IsMounted);
emit newBigFolder(path, isExternalStorage);
emit existingFolderNowBig(path);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/libsync/discoveryphase.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class DiscoveryPhase : public QObject
const RemotePermissions rp,
const std::function<void(bool)> callback);

void checkSelectiveSyncExistingFolder(const QString &path, const RemotePermissions &rp, const qint64 folderSize);
void checkSelectiveSyncExistingFolder(const QString &path, const qint64 folderSize);

/** Given an original path, return the target path obtained when renaming is done.
*
Expand Down Expand Up @@ -323,6 +323,7 @@ class DiscoveryPhase : public QObject

// A new folder was discovered and was not synced because of the confirmation feature
void newBigFolder(const QString &folder, bool isExternal);
void existingFolderNowBig(const QString &folder);

/** For excluded items that don't show up in itemDiscovered()
*
Expand Down
1 change: 1 addition & 0 deletions src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ void SyncEngine::startSync()

connect(_discoveryPhase.data(), &DiscoveryPhase::itemDiscovered, this, &SyncEngine::slotItemDiscovered);
connect(_discoveryPhase.data(), &DiscoveryPhase::newBigFolder, this, &SyncEngine::newBigFolder);
connect(_discoveryPhase.data(), &DiscoveryPhase::existingFolderNowBig, this, &SyncEngine::existingFolderNowBig);
connect(_discoveryPhase.data(), &DiscoveryPhase::fatalError, this, [this](const QString &errorString, ErrorCategory errorCategory) {
Q_EMIT syncError(errorString, errorCategory);
finalize(false);
Expand Down
2 changes: 2 additions & 0 deletions src/libsync/syncengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ public slots:
// A new folder was discovered and was not synced because of the confirmation feature
void newBigFolder(const QString &folder, bool isExternal);

void existingFolderNowBig(const QString &folder);

/** Emitted when propagation has problems with a locked file.
*
* Forwarded from OwncloudPropagator::seenLockedFile.
Expand Down

0 comments on commit d61f07e

Please sign in to comment.