mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-11 14:48:22 +00:00
Fix include/exclude filter issue
This commit is contained in:
parent
0e5bed3ae5
commit
6fb7ac44b6
2 changed files with 19 additions and 6 deletions
|
@ -49,10 +49,11 @@ class ItemIter(object):
|
|||
return item
|
||||
|
||||
def get_next(self):
|
||||
n = next(self.unpacker)
|
||||
while self.filter and not self.filter(n):
|
||||
while True:
|
||||
n = next(self.unpacker)
|
||||
return n
|
||||
decode_dict(n, (b'path', b'source', b'user', b'group'))
|
||||
if not self.filter or self.filter(n):
|
||||
return n
|
||||
|
||||
def peek(self):
|
||||
while True:
|
||||
|
@ -143,7 +144,6 @@ class Archive(object):
|
|||
unpacker.feed(self.key.decrypt(id, chunk))
|
||||
iter = ItemIter(unpacker, filter)
|
||||
for item in iter:
|
||||
decode_dict(item, (b'path', b'source', b'user', b'group'))
|
||||
yield item, iter.peek
|
||||
|
||||
def add_item(self, item):
|
||||
|
|
17
darc/test.py
17
darc/test.py
|
@ -137,6 +137,18 @@ class Test(unittest.TestCase):
|
|||
# end the same way as info_output
|
||||
assert info_output2.endswith(info_output)
|
||||
|
||||
def test_extract_include_exclude(self):
|
||||
self.darc('init', self.repository_location)
|
||||
self.create_regual_file('file1', size=1024 * 80)
|
||||
self.create_regual_file('file2', size=1024 * 80)
|
||||
self.create_regual_file('file3', size=1024 * 80)
|
||||
self.create_regual_file('file4', size=1024 * 80)
|
||||
self.darc('create', '--exclude=input/file4', self.repository_location + '::test', 'input')
|
||||
self.darc('extract', '--include=file1', self.repository_location + '::test', 'output')
|
||||
self.assertEqual(sorted(os.listdir('output/input')), ['file1'])
|
||||
self.darc('extract', '--exclude=file2', self.repository_location + '::test', 'output')
|
||||
self.assertEqual(sorted(os.listdir('output/input')), ['file1', 'file3'])
|
||||
|
||||
def test_overwrite(self):
|
||||
self.create_regual_file('file1', size=1024 * 80)
|
||||
self.create_regual_file('dir2/file2', size=1024 * 80)
|
||||
|
@ -222,10 +234,11 @@ def suite():
|
|||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(ChunkTest))
|
||||
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(Test))
|
||||
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(RemoteTest))
|
||||
if not '--no-remote' in sys.argv:
|
||||
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(RemoteTest))
|
||||
suite.addTest(RemoteRepositorySuite())
|
||||
suite.addTest(KeySuite())
|
||||
suite.addTest(RepositorySuite())
|
||||
suite.addTest(RemoteRepositorySuite())
|
||||
suite.addTest(doctest.DocTestSuite(helpers))
|
||||
suite.addTest(lrucache.suite())
|
||||
suite.addTest(crypto.suite())
|
||||
|
|
Loading…
Add table
Reference in a new issue