This repository was archived by the owner on May 23, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments