Skip to content

Commit

Permalink
Merge pull request #25 from Autodesk/fix-docker-directory-archive
Browse files Browse the repository at this point in the history
Fix docker directory archive
  • Loading branch information
avirshup authored Mar 6, 2018
2 parents 812da57 + 4d5b69c commit 89bb7c6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pyccc/files/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@ def put(self, destination):
members = []
for tarinfo in tf:
# Get only files under the directory `self.dirname`
pathsplit = os.path.split(tarinfo.path)
pathsplit = os.path.normpath(tarinfo.path).split(os.sep)
if pathsplit[0] not in valid_paths:
print('WARNING: skipped file "%s" in archive; not in directory "%s"' %
(tarinfo.path, self.dirname))
continue
if len(pathsplit) == 1:
continue
tarinfo.name = os.path.join(*pathsplit[1:])
members.append(tarinfo)

Expand Down
16 changes: 16 additions & 0 deletions pyccc/tests/test_dir_refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,19 @@ def test_put_directory_reference_with_renaming(request, fixturename, tmpdir, rel
assert not mismatch
assert not errors


def test_get_directory_with_subdirs(tmpdir):
engine = pyccc.Docker()
tmpdir = str(tmpdir)

cmd = ("mkdir -p /opt/blah/fugu && echo a > /opt/blah/a"
" && echo b > /opt/blah/b && echo fish > /opt/blah/fugu/fish")

job = engine.launch(image='alpine',
workingdir='/test',
command=cmd)
job.wait()
outdir = job.get_directory('/opt/blah')
outdir.put(tmpdir)
for path in ['a', 'b', 'fugu/fish']:
assert os.path.exists(os.path.join(tmpdir, 'blah', path))

0 comments on commit 89bb7c6

Please sign in to comment.