Skip to content

Commit

Permalink
Discovery: Ensure selective sync lists are sorted #6958
Browse files Browse the repository at this point in the history
  • Loading branch information
ckamm committed Jan 18, 2019
1 parent ad81454 commit 55eda59
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
12 changes: 12 additions & 0 deletions src/libsync/discoveryphase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,18 @@ void DiscoveryPhase::startJob(ProcessDirectoryJob *job)
job->start();
}

void DiscoveryPhase::setSelectiveSyncBlackList(const QStringList &list)
{
_selectiveSyncBlackList = list;
std::sort(_selectiveSyncBlackList.begin(), _selectiveSyncBlackList.end());
}

void DiscoveryPhase::setSelectiveSyncWhiteList(const QStringList &list)
{
_selectiveSyncWhiteList = list;
std::sort(_selectiveSyncWhiteList.begin(), _selectiveSyncWhiteList.end());
}

void DiscoveryPhase::scheduleMoreJobs()
{
auto limit = qMax(1, _syncOptions._parallelNetworkJobs);
Expand Down
9 changes: 7 additions & 2 deletions src/libsync/discoveryphase.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ class DiscoveryPhase : public QObject
QMap<QString, QString> _renamedItems; // map source -> destinations
int _currentlyActiveJobs = 0;

// both must contain a sorted list
QStringList _selectiveSyncBlackList;
QStringList _selectiveSyncWhiteList;

void scheduleMoreJobs();

bool isInSelectiveSyncBlackList(const QString &path) const;
Expand Down Expand Up @@ -167,8 +171,6 @@ class DiscoveryPhase : public QObject
SyncJournalDb *_statedb;
AccountPtr _account;
SyncOptions _syncOptions;
QStringList _selectiveSyncBlackList;
QStringList _selectiveSyncWhiteList;
ExcludedFiles *_excludes;
QRegExp _invalidFilenameRx; // FIXME: maybe move in ExcludedFiles
QStringList _serverBlacklistedFiles; // The blacklist from the capabilities
Expand All @@ -177,6 +179,9 @@ class DiscoveryPhase : public QObject

void startJob(ProcessDirectoryJob *);

void setSelectiveSyncBlackList(const QStringList &list);
void setSelectiveSyncWhiteList(const QStringList &list);

// output
QByteArray _dataFingerprint;

Expand Down
4 changes: 2 additions & 2 deletions src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,8 @@ void SyncEngine::startSync()
_discoveryPhase->_remoteFolder+='/';
_discoveryPhase->_syncOptions = _syncOptions;
_discoveryPhase->_shouldDiscoverLocaly = [this](const QString &s) { return shouldDiscoverLocally(s); };
_discoveryPhase->_selectiveSyncBlackList = selectiveSyncBlackList;
_discoveryPhase->_selectiveSyncWhiteList = _journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList, &ok);
_discoveryPhase->setSelectiveSyncBlackList(selectiveSyncBlackList);
_discoveryPhase->setSelectiveSyncWhiteList(_journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList, &ok));
if (!ok) {
qCWarning(lcEngine) << "Unable to read selective sync list, aborting.";
syncError(tr("Unable to read from the sync journal."));
Expand Down

0 comments on commit 55eda59

Please sign in to comment.