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:
commit
33599b9115
2 changed files with 1 additions and 2 deletions
|
@ -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:
|
||||
|
|
|
@ -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"))
|
||||
|
|
Loading…
Reference in a new issue