Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-3.5] if an exclude file is deleted, skip it and remove it from internal list #4548

Merged
merged 1 commit into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/csync/csync_exclude.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,26 @@ bool ExcludedFiles::reloadExcludeFiles()
bool success = true;
const auto keys = _excludeFiles.keys();
for (const auto& basePath : keys) {
for (const auto &excludeFile : _excludeFiles.value(basePath)) {
const auto itValue = _excludeFiles.find(basePath);
if (itValue == std::end(_excludeFiles)) {
continue;
}
auto &excludeFiles = *itValue;
for (auto excludeFileIt = std::begin(excludeFiles); excludeFileIt != std::end(excludeFiles); ) {
const auto &excludeFile = *excludeFileIt;
QFile file(excludeFile);
if (file.exists() && file.open(QIODevice::ReadOnly)) {
if (!file.exists()) {
excludeFileIt = excludeFiles.erase(excludeFileIt);
continue;
}

if (file.open(QIODevice::ReadOnly)) {
loadExcludeFilePatterns(basePath, file);
} else {
success = false;
qWarning() << "System exclude list file could not be opened:" << excludeFile;
}
++excludeFileIt;
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/testexcludedfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,11 +746,11 @@ private slots:
QCOMPARE(excludedFiles->_excludeFiles[folder2].first(), folder2ExcludeList);
}

void testReloadExcludeFiles_fileDoesNotExist_returnFalse() {
void testReloadExcludeFiles_fileDoesNotExist_returnTrue() {
excludedFiles.reset(new ExcludedFiles());
const QString nonExistingFile("directory/.sync-exclude.lst");
excludedFiles->addExcludeFilePath(nonExistingFile);
QCOMPARE(excludedFiles->reloadExcludeFiles(), false);
QCOMPARE(excludedFiles->reloadExcludeFiles(), true);
QCOMPARE(excludedFiles->_allExcludes.size(), 0);
}

Expand Down