return match
- def _recursive_walk_dir(self, source_path, strip_base_dir = False):
+ def _recursive_walk_dir(self, source_path, keep_base_dir=False):
'''
Walk a directory recursively, yielding each file/directory
'''
- queue = [source_path]
+ source_path = source_path.rstrip(os.sep)
- if strip_base_dir:
- beginning_size = len(source_path)
- else:
+ if keep_base_dir:
beginning_size = 0
+ else:
+ beginning_size = len(source_path) + 1 # +1 for os.sep
+
+ queue = [source_path]
+
while queue:
cur_path = queue.pop(0)
return
# to preserve parent directory mtime, we save it
- parent_dir = os.path.dirname(path)
+ parent_dir = os.path.dirname(path) or os.getcwd()
parent_dir_mtime = int(os.stat(parent_dir).st_mtime)
if os.path.isdir(path) and not os.path.islink(path):
upath = self._deltatar.unprefixed(path)
# to preserve parent directory mtime, we save it
- parent_dir = os.path.dirname(upath)
+ parent_dir = os.path.dirname(upath) or os.getcwd()
if not os.path.exists(parent_dir):
os.makedirs(parent_dir)
parent_dir_mtime = int(os.stat(parent_dir).st_mtime)