rustic
rustic copied to clipboard
RFC: improving glob matching
Current limitations
Tested on rustic v0.7.0
-
You should specify nested folders separately, e.g.
[[backup.sources]] source = "/dir" glob = [ "!*", "/dir/a", # without this line it won't work "/dir/a/**/*", ] -
File matching is affected by order of the glob patterns in config, but should be based on globs precedence. For example, this excludes
a/b.txt:[[backup.sources]] source = "/dir" glob = [ "!*", "/dir/a", "/dir/a/**/*", "!/dir/a/b.txt", ]but this don't:
[[backup.sources]] source = "/dir" glob = [ "!*", "/dir/a", "!/dir/a/b.txt", "/dir/a/**/*", ] -
Relative paths don't match files, only folders, e.g. this won't backup files, only folders:
[[backup.sources]] source = "/dir" glob = [ "!*", "a", "a/**/*", ] -
Specifying folder without
/**/*backups only this folder and not any of its content, but this is useless and inconsistent with the fact that whenglobisn't specified, the source is backed up recursively. -
More?
Requirements of the new implementation
-
Relative paths works properly.
-
You don't need to specify nested folders separately.
-
When specifying folder, it's content included recursively (but you can specify this explicitly, so
"a" == "a/**/*"). -
If a file/subfolder is specified separately, it takes precedence over the specified parent folder, regardless of its position in the list.
-
It's possible to include only files, but not subfolders, like
glob = [ "a/*", "!a/**/*" ]or
glob = [ "a/*", "!a/**/" ]or even just
glob = [ "a/*" ] -
More?
Why new implementation?
I'm not sure that walkdir can give such flexibility.
Backward compatibility
TODO