mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 23:00:58 +00:00
3297624037
This improves the ignore handling so that directories can be fully ignored (skipped in the watcher) in more cases. Specifically, where the previous rule was that any complex `!`-pattern would disable skipping directories, the new rule is that only matches on patterns *after* such a `!`-pattern disable skipping. That is, the following now does the intuitive thing: ``` /foo /bar !whatever * ``` - `/foo/**` and `/bar/**` are completely skipped, since there is no chance anything underneath them could ever be not-ignored - `!whatever` toggles the "can't skip directories any more" flag - Anything that matches `*` can't skip directories, because it's possible we can have `whatever` match something deeper. To enable this, some refactoring was necessary: - The "can skip dirs" flag is now a property of the match result, not of the pattern set as a whole. - That meant returning a boolean is not good enough, we need to actually return the entire `Result` (or, like, two booleans but that seemed uglier and more annoying to use) - `ShouldIgnore(string) boolean` went away with `Match(string).IsIgnored()` being the obvious replacement (API simplification!) - The watcher then needed to import the `ignore` package (for the `Result` type), but `fs` imports the watcher and `ignore` imports `fs`. That's a cycle, so I broke out `Result` into a package of its own so that it can be safely imported everywhere in things like `type Matcher interface { Match(string) result.Result }`. There's a fair amount of stuttering in `result.Result` and maybe we should go with something like `ignoreresult.R` or so, leaving this open for discussion. Tests refactored to suit, I think this change is in fact quite well covered by the existing ones... Also some noise because a few of the changed files were quite old and got the `gofumpt` treatment by my editor. Sorry not sorry. --------- Co-authored-by: Simon Frei <freisim93@gmail.com> |
||
---|---|---|
.. | ||
basicfs_copy_range_copyfilerange.go | ||
basicfs_copy_range_duplicateextents.go | ||
basicfs_copy_range_ioctl.go | ||
basicfs_copy_range_sendfile.go | ||
basicfs_copy_range.go | ||
basicfs_fileinfo_bsdish.go | ||
basicfs_fileinfo_linuxish.go | ||
basicfs_fileinfo_unix.go | ||
basicfs_fileinfo_windows.go | ||
basicfs_lstat_broken.go | ||
basicfs_lstat_regular.go | ||
basicfs_lstat_windows.go | ||
basicfs_platformdata_unix.go | ||
basicfs_platformdata_windows.go | ||
basicfs_test.go | ||
basicfs_unix.go | ||
basicfs_watch_errors_linux.go | ||
basicfs_watch_errors_others.go | ||
basicfs_watch_eventtypes_darwin.go | ||
basicfs_watch_eventtypes_fen.go | ||
basicfs_watch_eventtypes_inotify.go | ||
basicfs_watch_eventtypes_kqueue.go | ||
basicfs_watch_eventtypes_other.go | ||
basicfs_watch_eventtypes_readdcw.go | ||
basicfs_watch_notkqueue.go | ||
basicfs_watch_test.go | ||
basicfs_watch_unsupported.go | ||
basicfs_watch.go | ||
basicfs_windows_test.go | ||
basicfs_windows.go | ||
basicfs_xattr_bsdish.go | ||
basicfs_xattr_linuxish.go | ||
basicfs_xattr_unix.go | ||
basicfs_xattr_unsupported.go | ||
basicfs.go | ||
casefs_test.go | ||
casefs.go | ||
copyrangemethod.go | ||
copyrangemethod.pb.go | ||
debug.go | ||
errorfs.go | ||
fakefs_test.go | ||
fakefs.go | ||
filesystem_copy_range_allwithfallback.go | ||
filesystem_copy_range_standard.go | ||
filesystem_copy_range_test.go | ||
filesystem_copy_range.go | ||
filesystem_test.go | ||
filesystem.go | ||
folding_test.go | ||
folding.go | ||
logfs.go | ||
metrics.go | ||
mtimefs_test.go | ||
mtimefs.go | ||
platform_common.go | ||
tempname_test.go | ||
tempname.go | ||
types.go | ||
types.pb.go | ||
util_test.go | ||
util.go | ||
walkfs_test.go | ||
walkfs.go |