1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-01-01 12:45:34 +00:00

Merge pull request #7509 from ThomasWaldmann/build-filter-microopt

build_filter: micro opt / easier code, fixes #3390
This commit is contained in:
TW 2023-04-08 17:11:40 +02:00 committed by GitHub
commit 33599b9115
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 2 deletions

View file

@ -591,7 +591,7 @@ def build_filter(matcher, strip_components):
if strip_components:
def item_filter(item):
matched = matcher.match(item.path) and os.sep.join(item.path.split(os.sep)[strip_components:])
matched = matcher.match(item.path) and len(item.path.split(os.sep)) > strip_components
return matched
else:

View file

@ -22,6 +22,5 @@ def test_strip_components(self):
matcher = PatternMatcher(fallback=True)
filter = build_filter(matcher, strip_components=1)
assert not filter(Item(path="shallow"))
assert not filter(Item(path="shallow/")) # can this even happen? paths are normalized...
assert filter(Item(path="deep enough/file"))
assert filter(Item(path="something/dir/file"))