Skip to content

lib/ignore: Keep skipping ignored dirs for rooted patterns - #6151

Merged
AudriusButkevicius merged 7 commits into
syncthing:masterfrom
imsodin:ignore/optIncl
Nov 26, 2019
Merged

AudriusButkevicius merged 7 commits into
syncthing:masterfrom
imsodin:ignore/optIncl

Conversation

@imsodin

@imsodin imsodin commented Nov 12, 2019

Copy link
Copy Markdown
Member

Purpose

This came up a few times, most recently here: https://forum.syncthing.net/t/how-to-correctly-exclude-all-files-and-folders-except-folder-abc-and-def/14062
For most include patterns we need to traverse everything to catch them, but for rooted patterns without wildcards in all but the last part of the path we don't actually.

Testing

To test this I needed to refactor to have a function that creates patterns from lines/strings instead of files/readers.

Comment thread lib/ignore/ignore.go Resolved
Comment thread lib/ignore/ignore.go Resolved
Comment thread lib/ignore/ignore.go Resolved
Comment thread lib/ignore/ignore_test.go Resolved
Comment thread lib/ignore/ignore.go Resolved
Comment thread lib/ignore/ignore_test.go Resolved
Comment thread lib/ignore/ignore.go Resolved
Comment thread lib/ignore/ignore.go Outdated
return false
}
// need to check for escapes
for i := strings.Index(comp, "["); i != -1; i = strings.Index(comp[i+1:], "[") {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are also ? wildcards and {bracketed,alternatives}, should we check for those?

Also escapes are not processed on Windows, so \[foo] there is a rooted path with a wildcard expression in it...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really shouldn't handle this globbing stuff manually...
I switched to using glob.QuoteMeta to check for any "special stuff". That has the limitation that it doesn't work with escaped brackets \[. So this optimization will not apply to any include patterns with such in them.

calmh
calmh previously approved these changes Nov 25, 2019
@AudriusButkevicius

Copy link
Copy Markdown
Member

I'd like to have a better look at this in front of a bigger screen

Comment thread lib/ignore/ignore.go Resolved
Comment thread lib/ignore/ignore.go Resolved
@AudriusButkevicius
AudriusButkevicius merged commit f747ba6 into syncthing:master Nov 26, 2019
@imsodin
imsodin deleted the ignore/optIncl branch November 26, 2019 08:07
@calmh calmh added this to the v1.3.3 milestone Nov 26, 2019
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Nov 26, 2020
@syncthing syncthing locked and limited conversation to collaborators Nov 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants