Skip to content

Commit 89bb7c6

Browse files
authored
Merge pull request #25 from Autodesk/fix-docker-directory-archive
Fix docker directory archive
2 parents 812da57 + 4d5b69c commit 89bb7c6

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

pyccc/files/directory.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,13 @@ def put(self, destination):
7979
members = []
8080
for tarinfo in tf:
8181
# Get only files under the directory `self.dirname`
82-
pathsplit = os.path.split(tarinfo.path)
82+
pathsplit = os.path.normpath(tarinfo.path).split(os.sep)
8383
if pathsplit[0] not in valid_paths:
8484
print('WARNING: skipped file "%s" in archive; not in directory "%s"' %
8585
(tarinfo.path, self.dirname))
8686
continue
87+
if len(pathsplit) == 1:
88+
continue
8789
tarinfo.name = os.path.join(*pathsplit[1:])
8890
members.append(tarinfo)
8991

pyccc/tests/test_dir_refs.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,19 @@ def test_put_directory_reference_with_renaming(request, fixturename, tmpdir, rel
8484
assert not mismatch
8585
assert not errors
8686

87+
88+
def test_get_directory_with_subdirs(tmpdir):
89+
engine = pyccc.Docker()
90+
tmpdir = str(tmpdir)
91+
92+
cmd = ("mkdir -p /opt/blah/fugu && echo a > /opt/blah/a"
93+
" && echo b > /opt/blah/b && echo fish > /opt/blah/fugu/fish")
94+
95+
job = engine.launch(image='alpine',
96+
workingdir='/test',
97+
command=cmd)
98+
job.wait()
99+
outdir = job.get_directory('/opt/blah')
100+
outdir.put(tmpdir)
101+
for path in ['a', 'b', 'fugu/fish']:
102+
assert os.path.exists(os.path.join(tmpdir, 'blah', path))

0 commit comments

Comments
 (0)