Check if there are patterns associated with a sync exclude file.

The previous check didn't take into the account that .sync-exclude.lst
might be empty which would crash at Q_ASSERT(_allExcludes.contains(basePath))
in the prepare function. It also takes into account that
_allExcludes[basePath] was creating new items in the list.

Signed-off-by: Camila <hello@camila.codes>
This commit is contained in:
Camila 2020-10-27 18:59:05 +01:00
Родитель 998e93ac13
Коммит bdd3465e7b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7A4A6121E88E2AD4
1 изменённых файлов: 5 добавлений и 2 удалений

Просмотреть файл

@ -317,17 +317,20 @@ bool ExcludedFiles::loadExcludeFile(const QByteArray & basePath, const QString &
if (!f.open(QIODevice::ReadOnly))
return false;
QList<QByteArray> patterns;
while (!f.atEnd()) {
QByteArray line = f.readLine().trimmed();
if (line.isEmpty() || line.startsWith('#'))
continue;
csync_exclude_expand_escapes(line);
_allExcludes[basePath].append(line);
patterns.append(line);
}
_allExcludes.insert(basePath, patterns);
// nothing to prepare if the user decided to not exclude anything
if(_allExcludes.size())
if (!_allExcludes.value(basePath).isEmpty()){
prepare(basePath);
}
return true;
}