Selective Sync: ensure that the blacklist contains the last '/'

In the sync engine.  Because that makes tha tthe lower_bounds in selective sync works properly.

For example, if both "Test" and "Test Test" are in the list,  then "Test/Foo" would match the "Test Test"
 because slash is after space

Task #2289
This commit is contained in:
Olivier Goffart 2014-10-09 15:11:04 +02:00
parent 97560509ea
commit 6de104a03a
3 changed files with 18 additions and 3 deletions

View file

@ -35,11 +35,16 @@ bool DiscoveryJob::isInBlackList(const QString& path) const
auto it = std::lower_bound(_selectiveSyncBlackList.begin(), _selectiveSyncBlackList.end(), pathSlash);
if (it != _selectiveSyncBlackList.end() && *it == pathSlash) {
return true;
}
if (it == _selectiveSyncBlackList.begin()) {
return false;
}
--it;
if (pathSlash.startsWith(*it + QLatin1Char('/'))) {
Q_ASSERT(*it.endsWith(QLatin1Char('/'))); // SyncEngine::setSelectiveSyncBlackList makes sure of that
if (pathSlash.startsWith(*it)) {
return true;
}
return false;

View file

@ -1041,6 +1041,17 @@ QByteArray SyncEngine::getPermissions(const QString& file) const
return _remotePerms.value(file);
}
void SyncEngine::setSelectiveSyncBlackList(const QStringList& list)
{
_selectiveSyncBlackList = list;
for (int i = 0; i < _selectiveSyncBlackList.count(); ++i) {
if (!_selectiveSyncBlackList.at(i).endsWith(QLatin1Char('/'))) {
_selectiveSyncBlackList[i].append(QLatin1Char('/'));
}
}
}
void SyncEngine::abort()
{

View file

@ -61,8 +61,7 @@ public:
Utility::StopWatch &stopWatch() { return _stopWatch; }
void setSelectiveSyncBlackList(const QStringList &list)
{ _selectiveSyncBlackList = list; }
void setSelectiveSyncBlackList(const QStringList &list);
/* Return true if we detected that another sync is needed to complete the sync */
bool isAnotherSyncNeeded() { return _anotherSyncNeeded; }