From 182b3b67fbfc6ebdafbefbdb10ec0e6fb0a56f53 Mon Sep 17 00:00:00 2001 From: David Zuelke Date: Mon, 7 Apr 2014 19:59:55 +0200 Subject: [PATCH] Revert "cleaned up archive_tree function" This reverts commit 1d03df5c8588e297a287de07cb89dbf666308773. --- bob/utils.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bob/utils.py b/bob/utils.py index b6880e3..7ce4764 100644 --- a/bob/utils.py +++ b/bob/utils.py @@ -48,6 +48,7 @@ def archive_tree(dir, archive): abspath = os.path.abspath(dir) base_root = None + transposed_base = None is_top_level = False with tarfile.open(archive, 'w:gz') as tar: @@ -61,13 +62,18 @@ def archive_tree(dir, archive): if not base_root: base_root = root - transposed_base = root[len(base_root)+1:] + # No path at all for the top-level directory. + if not is_top_level: + transposed_base = root[len(base_root)+1:] + else: + transposed_base = '' + for file in files: standard_path = os.path.join(root, file) - if is_top_level: + if not transposed_base: transposed_path = file else: transposed_path = os.path.join(transposed_base, file) @@ -75,6 +81,7 @@ def archive_tree(dir, archive): # Add the file to the archive, with the proper transposed path. tar.add(standard_path, arcname=transposed_path) + # Close out the top-level directory marker. is_top_level = False