From 120fe44f4f563d584bc0718f29b6dcab96312230 Mon Sep 17 00:00:00 2001 From: mosandlt <10558666+mosandlt@users.noreply.github.com> Date: Thu, 2 Jul 2026 05:47:14 +0200 Subject: [PATCH] fix(cmd,csync): don't silently ignore a missing --exclude file nextcloudcmd's ExcludedFiles::reloadExcludeFiles() dropped a registered exclude file from the list without any warning when QFile::exists() returned false, and still reported success. A mistyped or unresolved --exclude path (e.g. a relative path that resolves differently under cron than interactively) therefore made nextcloudcmd sync everything with zero exclusions and no diagnostic in the log. - csync_exclude.cpp: log a qWarning when a registered exclude file can't be found, instead of silently erasing it. - cmd.cpp: fail fast with qFatal when a user-supplied --exclude path doesn't exist, instead of only discovering it deep inside reloadExcludeFiles() with no way to distinguish "path is wrong" from "path was never wrong to begin with". Fixes #4621 Signed-off-by: mosandlt <10558666+mosandlt@users.noreply.github.com> --- src/cmd/cmd.cpp | 9 +++++++++ src/csync/csync_exclude.cpp | 1 + 2 files changed, 10 insertions(+) diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp index 78be38da19d61..d55582588d64a 100644 --- a/src/cmd/cmd.cpp +++ b/src/cmd/cmd.cpp @@ -547,6 +547,15 @@ int main(int argc, char **argv) // Always try to load the user-provided exclude list if one is specified if (hasUserExcludeFile) { + if (!QFile::exists(options.exclude)) { + // A user-supplied --exclude path that can't be found is a + // configuration error, not something to silently ignore: + // reloadExcludeFiles() below drops missing files without + // failing, which previously made the whole sync run with + // no exclusions and no diagnostic (see nextcloud/desktop#4621). + qFatal("Exclude list file supplied via --exclude does not exist: %s", qUtf8Printable(options.exclude)); + return EXIT_FAILURE; + } engine.excludedFiles().addExcludeFilePath(options.exclude); } // Load the system list if available, or if there's no user-provided list diff --git a/src/csync/csync_exclude.cpp b/src/csync/csync_exclude.cpp index 72e585aea7bc1..438fa9aac3851 100644 --- a/src/csync/csync_exclude.cpp +++ b/src/csync/csync_exclude.cpp @@ -346,6 +346,7 @@ bool ExcludedFiles::reloadExcludeFiles() const auto &excludeFile = *excludeFileIt; QFile file(excludeFile); if (!file.exists()) { + qWarning() << "Exclude list file does not exist, skipping:" << excludeFile; excludeFileIt = excludeFiles.erase(excludeFileIt); continue; }