Show More
@@ -26,6 +26,7 b'' | |||
|
26 | 26 | import os |
|
27 | 27 | import logging |
|
28 | 28 | import traceback |
|
29 | import tempfile | |
|
29 | 30 | |
|
30 | 31 | from pylons import request, response, tmpl_context as c, url |
|
31 | 32 | from pylons.i18n.translation import _ |
@@ -359,25 +360,22 b' class FilesController(BaseRepoController' | |||
|
359 | 360 | except (ImproperArchiveTypeError, KeyError): |
|
360 | 361 | return _('Unknown archive type') |
|
361 | 362 | |
|
363 | archive = tempfile.NamedTemporaryFile(mode='w+r+b') | |
|
364 | cs.fill_archive(stream=archive, kind=fileformat, subrepos=subrepos) | |
|
365 | ||
|
362 | 366 | response.content_type = content_type |
|
363 | 367 | response.content_disposition = 'attachment; filename=%s-%s%s' \ |
|
364 | % (repo_name, revision, ext) | |
|
365 | ||
|
366 | import tempfile | |
|
367 | archive = tempfile.mkstemp()[1] | |
|
368 | t = open(archive, 'wb') | |
|
369 | cs.fill_archive(stream=t, kind=fileformat, subrepos=subrepos) | |
|
368 | % (repo_name, revision[:12], ext) | |
|
369 | response.content_length = str(os.path.getsize(archive.name)) | |
|
370 | 370 | |
|
371 |
def get_chunked_archive( |
|
|
372 | stream = open(archive, 'rb') | |
|
371 | def get_chunked_archive(tmpfile): | |
|
373 | 372 | while True: |
|
374 |
data = |
|
|
373 | data = tmpfile.read(16 * 1024) | |
|
375 | 374 | if not data: |
|
376 |
|
|
|
375 | tmpfile.close() | |
|
377 | 376 | break |
|
378 | 377 | yield data |
|
379 | ||
|
380 | return get_chunked_archive(archive) | |
|
378 | return get_chunked_archive(tmpfile=archive) | |
|
381 | 379 | |
|
382 | 380 | @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
|
383 | 381 | 'repository.admin') |
@@ -263,8 +263,6 b' class MercurialChangeset(BaseChangeset):' | |||
|
263 | 263 | archival.archive(self.repository._repo, stream, self.raw_id, |
|
264 | 264 | kind, prefix=prefix, subrepos=subrepos) |
|
265 | 265 | |
|
266 | #stream.close() | |
|
267 | ||
|
268 | 266 | if stream.closed and hasattr(stream, 'name'): |
|
269 | 267 | stream = open(stream.name, 'rb') |
|
270 | 268 | elif hasattr(stream, 'mode') and 'r' not in stream.mode: |
General Comments 0
You need to be logged in to leave comments.
Login now