Check if there are patterns associated with a sync exclude file.
authorCamila <hello@camila.codes>
Tue, 27 Oct 2020 17:59:05 +0000 (18:59 +0100)
committerCamila <hello@camila.codes>
Thu, 26 Nov 2020 11:12:04 +0000 (12:12 +0100)
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>
src/csync/csync_exclude.cpp

index b34a521cf42bf26bbc0c3b867d470dc33ab90a18..61bfdd443b7a67d8abf76eb533927341dd523035 100644 (file)
@@ -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;
 }