Skip to content

lib/ignore: Only skip for toplevel includes (fixes #6487) - #6508

Merged
calmh merged 2 commits into
syncthing:masterfrom
imsodin:ignore/skipFix
Apr 7, 2020
Merged

calmh merged 2 commits into
syncthing:masterfrom
imsodin:ignore/skipFix

Conversation

@imsodin

@imsodin imsodin commented Apr 6, 2020

Copy link
Copy Markdown
Member

Purpose

The assumption when "optimizing" includes in #6151, that all rooted patterns without wildcards do not require scanning the entire tree is just not correct - at least not without additional smarts. We'd have to make sure that all the parent path components are also included. That's definitely doable, but not something I am interested in right now. So I just dumbed the logic down to just optimize includes in the root, nowhere else.

Testing

I needed to adjust the unit testing in lib/ignore, but the relevant test reproducing #6151 is in lib/scanner.

calmh
calmh previously approved these changes Apr 7, 2020

@calmh calmh left a comment

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.

So this looked sane to me, but causes a test failure on Windows. Potentially the slash stuff needs to account for the platform local separator? We accept \ as separator in the patterns on Windows, in addition to forward slash...

@calmh
calmh dismissed their stale review April 7, 2020 06:35

not actually ok it seems

@calmh calmh left a comment

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.

I'm still confused about this though. I suspect the tests pass because the if p.pattern[0] != '/' means we never apply the optimizations on Windows, but really we should apply the optimization for like

!\foo
*

no?

@calmh

calmh commented Apr 7, 2020

Copy link
Copy Markdown
Member

Though I guess that's the anti-issue of the one this solves

@imsodin

imsodin commented Apr 7, 2020

Copy link
Copy Markdown
Member Author

Ignore patterns are slashes only, we don't accept backslashes there. Before matching we always use ToSlash in ignore.go: https://github.com/syncthing/syncthing/blame/master/lib/ignore/ignore.go#L255

The test originally failed on windows because I used a path with slashes to compare to FileInfo.Name, which uses native path separators, thus they were never equal.

@calmh

calmh commented Apr 7, 2020

Copy link
Copy Markdown
Member

But that happens after we load and parse and decide whether to optimize?

@imsodin

imsodin commented Apr 7, 2020

Copy link
Copy Markdown
Member Author

Yes, my link didn't point to the best place: The change in this PR acts on Pattern, and that is always in slashes, as we do convert .stignore contents to slashes: https://github.com/syncthing/syncthing/blame/master/lib/ignore/ignore.go#L506
So in your example !\foo results in pattern /foo with include flag set.

@calmh

calmh commented Apr 7, 2020

Copy link
Copy Markdown
Member

So it is!

@calmh
calmh merged commit 07ce357 into syncthing:master Apr 7, 2020
@imsodin
imsodin deleted the ignore/skipFix branch April 7, 2020 08:23
@calmh calmh added this to the v1.5.0 milestone Apr 13, 2020
@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 Apr 8, 2021
@syncthing syncthing locked and limited conversation to collaborators Apr 8, 2021
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.

3 participants