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

Commit e1841bb

Browse files
committed
fix empty leading slash entry, for real
this also preserves empty directories in tar files
1 parent b1439fd commit e1841bb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

bob/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ def pipe(a, b, indent=True):
4646
def archive_tree(dir, archive):
4747
"""Creates a tar.gz archive from a given directory."""
4848
with tarfile.open(archive, 'w:gz') as tar:
49-
tar.add(dir, arcname=os.path.basename(dir))
49+
# do not tar.add(dir) with empty arcname, that will create a "/" entry and tar will complain when extracting
50+
for item in os.listdir(dir):
51+
tar.add(dir+"/"+item, arcname=item)
5052

5153
def extract_tree(archive, dir):
5254
"""Extract tar.gz archive to a given directory."""

0 commit comments

Comments
 (0)