From 4ac6d333ecdec7318f0ce6ec3e3364f65056ea1b Mon Sep 17 00:00:00 2001 From: Eduardo Robles Elvira Date: Wed, 19 Mar 2014 13:16:29 +0100 Subject: [PATCH] making testbackup.py work --- deltatar/deltatar.py | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/deltatar/deltatar.py b/deltatar/deltatar.py index e01ccf6..2c1ded7 100644 --- a/deltatar/deltatar.py +++ b/deltatar/deltatar.py @@ -359,7 +359,7 @@ class DeltaTar(object): return match - def _recursive_walk_dir(self, source_path): + def _recursive_walk_dir(self, source_path, strip_base_dir = False): ''' Walk a directory recursively, yielding each file/directory ''' @@ -380,6 +380,10 @@ class DeltaTar(object): queue = [source_path] + if strip_base_dir: + beginging_size = len(source_path) + else: + beginging_size = 0 while queue: cur_path = queue.pop(0) @@ -392,7 +396,7 @@ class DeltaTar(object): status = self.filter_path(child, source_path, is_dir) if status == MATCH: - yield child + yield child[beginging_size:] if is_dir and (status == MATCH or status == PARENT_MATCH): queue.append(child) @@ -1046,11 +1050,11 @@ class DeltaTar(object): try: path = iter.__next__() if strip == 0: - yield self._stat_dict(path) + yield self._stat_dict(path), 0 else: st = self._stat_dict(path) st['path'] = "/".join(path.split("/")[strip:]) - yield st + yield st, 0 except StopIteration: break -- 1.7.1