Excludes: Don't redundantly add the same exclude files #4967, Never accept duplicate exclude patterns #4967
static
#endif
int _csync_exclude_add(c_strlist_t **inList, const char *string) {
+ size_t i = 0;
+
+ // We never want duplicates, so check whether the string is already
+ // in the list first.
+ if (*inList) {
+ for (i = 0; i < (*inList)->count; ++i) {
+ char *pattern = (*inList)->vector[i];
+ if (c_streq(pattern, string)) {
+ return 0;
+ }
+ }
+ }
return c_strlist_add_grow(inList, string);
}
bool Folder::setIgnoredFiles()
{
+ // Note: Doing this on each sync run and on Folder construction is
+ // unnecessary, because _engine->excludedFiles() persists between
+ // sync runs. This is not a big problem because ExcludedFiles maintains
+ // a QSet of files to load.
ConfigFile cfg;
QString systemList = cfg.excludeFile(ConfigFile::SystemScope);
if( QFile::exists(systemList) ) {
void ExcludedFiles::addExcludeFilePath(const QString& path)
{
- _excludeFiles.append(path);
+ _excludeFiles.insert(path);
}
bool ExcludedFiles::reloadExcludes()
#include "owncloudlib.h"
#include <QObject>
-#include <QStringList>
+#include <QSet>
+#include <QString>
extern "C" {
#include "std/c_string.h"
// This is a pointer to the csync exclude list, its is owned by this class
// but the pointer can be in a csync_context so that it can itself also query the list.
c_strlist_t** _excludesPtr;
- QStringList _excludeFiles;
+ QSet<QString> _excludeFiles;
};
} // namespace OCC