##// END OF EJS Templates
archive file fixes for python 2.5
marcink -
r2291:982d8a80 beta
parent child Browse files
Show More
@@ -22,7 +22,7 b''
22 #
22 #
23 # You should have received a copy of the GNU General Public License
23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25
25 from __future__ import with_statement
26 import os
26 import os
27 import logging
27 import logging
28 import traceback
28 import traceback
@@ -360,13 +360,14 b' class FilesController(BaseRepoController'
360 except (ImproperArchiveTypeError, KeyError):
360 except (ImproperArchiveTypeError, KeyError):
361 return _('Unknown archive type')
361 return _('Unknown archive type')
362
362
363 archive = tempfile.NamedTemporaryFile(mode='w+r+b', delete=False)
363 fd, _archive_name = tempfile.mkstemp(suffix='rcarchive')
364 cs.fill_archive(stream=archive, kind=fileformat, subrepos=subrepos)
364 with open(_archive_name, 'wb') as f:
365 archive.close()
365 cs.fill_archive(stream=f, kind=fileformat, subrepos=subrepos)
366
366 response.content_type = content_type
367 response.content_type = content_type
367 response.content_disposition = 'attachment; filename=%s-%s%s' \
368 response.content_disposition = 'attachment; filename=%s-%s%s' \
368 % (repo_name, revision[:12], ext)
369 % (repo_name, revision[:12], ext)
369 response.content_length = str(os.path.getsize(archive.name))
370 response.content_length = str(os.path.getsize(_archive_name))
370
371
371 def get_chunked_archive(tmpfile):
372 def get_chunked_archive(tmpfile):
372 while True:
373 while True:
@@ -376,7 +377,7 b' class FilesController(BaseRepoController'
376 os.unlink(tmpfile.name)
377 os.unlink(tmpfile.name)
377 break
378 break
378 yield data
379 yield data
379 return get_chunked_archive(tmpfile=open(archive.name,'rb'))
380 return get_chunked_archive(tmpfile=open(_archive_name, 'rb'))
380
381
381 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
382 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
382 'repository.admin')
383 'repository.admin')
General Comments 0
You need to be logged in to leave comments. Login now