Commit e5db10e
fix(cmd,csync): anchor --exclude patterns at the sync root regardless of filename
Summary
nextcloudcmd --exclude <path> silently produced zero exclusions for
every pattern in the file, unless <path> happened to be literally
named "sync-exclude.lst" -- with no warning or error anywhere. Any
other filename (a typo'd extension, a descriptive name, a per-tool
name like myapp-exclude.lst) caused every single pattern to be
matched against the wrong base directory, so none of them ever
excluded anything under the sync root.
Root cause
ExcludedFiles::addExcludeFilePath() in src/csync/csync_exclude.cpp
anchors patterns either at the sync root (_localPath) or at the
exclude file's own containing directory, based on a filename check:
literally "sync-exclude.lst" -> sync root, anything else -> own
directory. That heuristic was introduced in 5788f35 (2020-12-09,
"Skip sync exclude file from list of exclude files if it doesn't
exist") to merge two previously-separate code paths: the GUI's
global exclude list (always named sync-exclude.lst, lives outside
any sync folder, needs sync-root anchoring) and a per-directory
.sync-exclude.lst discovered during traversal (needs anchoring at
its own directory). It was a side effect of that merge, not a
deliberate choice -- the commit's own description and linked issue
are unrelated to anchoring behavior.
src/cmd/cmd.cpp passes the CLI's --exclude value into the same
function unconditionally, so it inherited this GUI-specific
heuristic even though CLI users can name their exclude file
anything. Reported independently by multiple users:
#2916, #7682, and a comment
diagnosing the exact same filename dependency on #2916.
Fix
Add an explicit anchorToLocalPath parameter to addExcludeFilePath()
(default false, preserving current behavior everywhere else) and set
it for the CLI's --exclude option in cmd.cpp, so its patterns are
always anchored at the sync root regardless of the file's name.
Test plan
- [x] New unit test:
testAddExcludeFilePath_anchorToLocalPath_bypassesFilenameHeuristic
- [x] Full ExcludedFilesTest suite: 25 passed, 0 failed
- [x] Manual repro against a live Nextcloud account: an --exclude file
not named sync-exclude.lst previously had zero effect (excluded
directories were downloaded anyway); after this fix they are
correctly skipped (FileIgnored) with no behavior change for
GUI-managed exclude lists.
Signed-off-by: Thomas Mosandl <mosandl@concreativ.de>
Assisted-by: ClaudeCode:claude-sonnet-51 parent c5223d3 commit e5db10e
4 files changed
Lines changed: 54 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
559 | | - | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
560 | 562 | | |
561 | 563 | | |
562 | 564 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | | - | |
| 245 | + | |
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | | - | |
| 249 | + | |
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
65 | 74 | | |
66 | 75 | | |
67 | 76 | | |
68 | 77 | | |
69 | 78 | | |
70 | 79 | | |
71 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
72 | 95 | | |
73 | | - | |
| 96 | + | |
74 | 97 | | |
75 | 98 | | |
76 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
759 | 759 | | |
760 | 760 | | |
761 | 761 | | |
762 | | - | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
763 | 787 | | |
764 | 788 | | |
765 | 789 | | |
| |||
0 commit comments