Avoid corruption of binary files embedded in gzip, bz2 and zip archives in the upload tool.

Add an option in the upload tool to disable the conversion of universal
line endings to Posix line endings.
This is useful for avoiding corruption of uploaded files when a binary
file is contained inside a gzip, bz2 and zip archive.

This fixes bug report: https://trello.com/card/issue-with-uploaded-2bit-gz-files/506338ce32ae458f6d15e4b3/702
This commit is contained in:
Gert Hulselmans
2013-05-27 20:55:52 +02:00
parent 7c4c69fd3e
commit fb01c3cc96
5 changed files with 26 additions and 6 deletions
+8 -4
View File
@@ -264,10 +264,14 @@ def add_file( dataset, registry, json_file, output_path ):
if link_data_only == 'copy_files':
if dataset.type in ( 'server_dir', 'path_paste' ) and data_type not in [ 'gzip', 'bz2', 'zip' ]:
in_place = False
if dataset.space_to_tab:
line_count, converted_path = sniff.convert_newlines_sep2tabs( dataset.path, in_place=in_place )
else:
line_count, converted_path = sniff.convert_newlines( dataset.path, in_place=in_place )
# Convert universal line endings to Posix line endings, but allow the user to turn it off,
# so that is becomes possible to upload gzip, bz2 or zip files with binary data without
# corrupting the content of those files.
if dataset.to_posix_lines:
if dataset.space_to_tab:
line_count, converted_path = sniff.convert_newlines_sep2tabs( dataset.path, in_place=in_place )
else:
line_count, converted_path = sniff.convert_newlines( dataset.path, in_place=in_place )
if dataset.file_type == 'auto':
ext = sniff.guess_ext( dataset.path, registry.sniff_order )
else:
+4 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<tool name="Upload File" id="upload1" version="1.1.3" workflow_compatible="false">
<tool name="Upload File" id="upload1" version="1.1.4" workflow_compatible="false">
<description>
from your computer
</description>
@@ -38,6 +38,9 @@
</param>
<param name="url_paste" type="text" area="true" size="5x35" label="URL/Text" help="Here you may specify a list of URLs (one per line) or paste the contents of a file."/>
<param name="ftp_files" type="ftpfile" label="Files uploaded via FTP"/>
<param name="to_posix_lines" type="select" display="checkboxes" multiple="True" label="Convert universal line endings to Posix line endings" help="Turn this option off if you upload a gzip, bz2 or zip archive which contains a binary file.">
<option value="Yes" selected="true">Yes</option>
</param>
<param name="space_to_tab" type="select" display="checkboxes" multiple="True" label="Convert spaces to tabs" help="Use this option if you are entering intervals by hand.">
<option value="Yes">Yes</option>
</param>