Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Commit 182b3b6

Browse files
committed
Revert "cleaned up archive_tree function"
This reverts commit 1d03df5.
1 parent c1a92d4 commit 182b3b6

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

bob/utils.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def archive_tree(dir, archive):
4848

4949
abspath = os.path.abspath(dir)
5050
base_root = None
51+
transposed_base = None
5152
is_top_level = False
5253

5354
with tarfile.open(archive, 'w:gz') as tar:
@@ -61,20 +62,26 @@ def archive_tree(dir, archive):
6162
if not base_root:
6263
base_root = root
6364

64-
transposed_base = root[len(base_root)+1:]
65+
# No path at all for the top-level directory.
66+
if not is_top_level:
67+
transposed_base = root[len(base_root)+1:]
68+
else:
69+
transposed_base = ''
70+
6571

6672
for file in files:
6773

6874
standard_path = os.path.join(root, file)
6975

70-
if is_top_level:
76+
if not transposed_base:
7177
transposed_path = file
7278
else:
7379
transposed_path = os.path.join(transposed_base, file)
7480

7581
# Add the file to the archive, with the proper transposed path.
7682
tar.add(standard_path, arcname=transposed_path)
7783

84+
7885
# Close out the top-level directory marker.
7986
is_top_level = False
8087

0 commit comments

Comments
 (0)