Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: improving glob matching #1151

Open
istudyatuni opened this issue May 11, 2024 · 0 comments
Open

RFC: improving glob matching #1151

istudyatuni opened this issue May 11, 2024 · 0 comments
Labels
S-triage Status: Waiting for a maintainer to triage this issue/PR

Comments

@istudyatuni
Copy link
Contributor

istudyatuni commented May 11, 2024

Current limitations

Tested on rustic v0.7.0

  1. You should specify nested folders separately, e.g.

    [[backup.sources]]
    source = "/dir"
    glob = [
        "!*",
        "/dir/a", # without this line it won't work
        "/dir/a/**/*",
    ]
  2. 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/**/*",
    ]
  3. Relative paths don't match files, only folders, e.g. this won't backup files, only folders:

    [[backup.sources]]
    source = "/dir"
    glob = [
        "!*",
        "a",
        "a/**/*",
    ]
  4. Specifying folder without /**/* backups only this folder and not any of its content, but this is useless and inconsistent with the fact that when glob isn't specified, the source is backed up recursively.

  5. More?

Requirements of the new implementation

  1. Relative paths works properly.

  2. You don't need to specify nested folders separately.

  3. When specifying folder, it's content included recursively (but you can specify this explicitly, so "a" == "a/**/*").

  4. If a file/subfolder is specified separately, it takes precedence over the specified parent folder, regardless of its position in the list.

  5. It's possible to include only files, but not subfolders, like

    glob = [
        "a/*",
        "!a/**/*"
    ]

    or

    glob = [
        "a/*",
        "!a/**/"
    ]

    or even just

    glob = [
        "a/*"
    ]
  6. More?

Why new implementation?

I'm not sure that walkdir can give such flexibility.

Backward compatibility

TODO

@github-actions github-actions bot added the S-triage Status: Waiting for a maintainer to triage this issue/PR label May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-triage Status: Waiting for a maintainer to triage this issue/PR
Projects
None yet
Development

No branches or pull requests

1 participant