Ver código fonte

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

build_filter: micro opt / easier code, fixes #3390
TW 2 anos atrás
pai
commit
33599b9115

+ 1 - 1
src/borg/archiver/_common.py

@@ -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:

+ 0 - 1
src/borg/testsuite/archiver/patterns.py

@@ -22,6 +22,5 @@ class TestBuildFilter:
         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"))