Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.09] History import fixes #5344

Merged
merged 4 commits into from
Jan 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/galaxy/tools/imp_exp/imp_history_from_archive.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<tool id="__IMPORT_HISTORY__" name="Import History" version="0.1" tool_type="import_history">
<type class="ImportHistoryTool" module="galaxy.tools"/>
<action module="galaxy.tools.actions.history_imp_exp" class="ImportHistoryToolAction"/>
<command interpreter="python">unpack_tar_gz_archive.py "${ str( $__ARCHIVE_SOURCE__ ).encode( 'base64' ) }" "${ str( $__DEST_DIR__ ).encode( 'base64' ) }" --$__ARCHIVE_TYPE__ --encoded</command>
<command>python '$__tool_directory__/unpack_tar_gz_archive.py' '${ str( $__ARCHIVE_SOURCE__ ).encode( 'base64' ) }' '${ str( $__DEST_DIR__ ).encode( 'base64' ) }' --$__ARCHIVE_TYPE__ --encoded</command>
<inputs>
<param name="__ARCHIVE_SOURCE__" type="text">
<sanitizer sanitize="False"/>
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/tools/imp_exp/unpack_tar_gz_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def check_archive(archive_file, dest_dir):
Ensure that a tar archive has no absolute paths or relative paths outside
the archive.
"""
with tarfile.open(archive_file, mode='r:gz') as archive_fp:
with tarfile.open(archive_file, mode='r') as archive_fp:
for arc_path in archive_fp.getnames():
assert os.path.normpath(
os.path.join(
Expand All @@ -64,7 +64,7 @@ def unpack_archive(archive_file, dest_dir):
"""
Unpack a tar and/or gzipped archive into a destination directory.
"""
archive_fp = tarfile.open(archive_file, mode='r:gz')
archive_fp = tarfile.open(archive_file, mode='r')
archive_fp.extractall(path=dest_dir)
archive_fp.close()

Expand Down
3 changes: 3 additions & 0 deletions lib/galaxy/webapps/galaxy/controllers/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,9 @@ def import_archive(self, trans, **kwargs):
archive_url = kwargs.get('archive_url', None)
archive_source = None
if hasattr(archive_file, 'file'):
# archive_file.file is a TemporaryFile and will be deleted once it is closed.
# We prevent this by setting `delete` to `False`.
archive_file.file.delete = False
archive_source = archive_file.file.name
archive_type = 'file'
elif archive_url:
Expand Down