[hg] galaxy 2591: Force FieldStorage to write tempfiles and neve...
details: http://www.bx.psu.edu/hg/galaxy/rev/0fb05cc2b05f changeset: 2591:0fb05cc2b05f user: Nate Coraor <nate@bx.psu.edu> date: Fri Aug 21 09:56:35 2009 -0400 description: Force FieldStorage to write tempfiles and never use StringIOs. 2 file(s) affected in this change: lib/galaxy/tools/actions/upload.py lib/galaxy/web/framework/base.py diffs (44 lines): diff -r 574cc8f15d2e -r 0fb05cc2b05f lib/galaxy/tools/actions/upload.py --- a/lib/galaxy/tools/actions/upload.py Thu Aug 20 17:33:39 2009 -0400 +++ b/lib/galaxy/tools/actions/upload.py Fri Aug 21 09:56:35 2009 -0400 @@ -20,12 +20,10 @@ for upload_dataset in incoming['files']: f = upload_dataset['file_data'] if isinstance( f, FieldStorage ): - # very small files can be StringIOs - if 'name' in dir( f.file ) and f.file.name != '<fdopen>': - local_filename = util.mkstemp_ln( f.file.name, 'upload_file_data_' ) - f.file.close() - else: - local_filename = datatypes.sniff.stream_to_file( f.file, prefix="strio_upload_file_" )[0] + assert not isinstance( f.file, StringIO.StringIO ) + assert f.file.name != '<fdopen>' + local_filename = util.mkstemp_ln( f.file.name, 'upload_file_data_' ) + f.file.close() upload_dataset['file_data'] = dict( filename = f.filename, local_filename = local_filename ) if upload_dataset['url_paste'].strip() != '': diff -r 574cc8f15d2e -r 0fb05cc2b05f lib/galaxy/web/framework/base.py --- a/lib/galaxy/web/framework/base.py Thu Aug 20 17:33:39 2009 -0400 +++ b/lib/galaxy/web/framework/base.py Fri Aug 21 09:56:35 2009 -0400 @@ -216,11 +216,18 @@ # tempfiles. Necessary for externalizing the upload tool. It's a little hacky # but for performance reasons it's way better to use Paste's tempfile than to # create a new one and copy. -import cgi +import cgi, tempfile class FieldStorage( cgi.FieldStorage ): def make_file(self, binary=None): - import tempfile return tempfile.NamedTemporaryFile() + def read_lines(self): + # Always make a new file + self.file = self.make_file() + self.__file = None + if self.outerboundary: + self.read_lines_to_outerboundary() + else: + self.read_lines_to_eof() cgi.FieldStorage = FieldStorage class Request( webob.Request ):
participants (1)
-
Greg Von Kuster