Mercurial > public > src > rhodecode
changeset 2393:0ba23ea7912a
merge with beta
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 17 May 2012 01:28:37 +0200 |
parents | 533a126dc9ab (current diff) 982d8a80e048 (diff) |
children | c5e1604ab342 |
files | rhodecode/controllers/files.py |
diffstat | 1 files changed, 7 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/controllers/files.py Thu May 17 00:55:35 2012 +0200 +++ b/rhodecode/controllers/files.py Thu May 17 01:28:37 2012 +0200 @@ -22,7 +22,7 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. - +from __future__ import with_statement import os import logging import traceback @@ -360,13 +360,14 @@ except (ImproperArchiveTypeError, KeyError): return _('Unknown archive type') - archive = tempfile.NamedTemporaryFile(mode='w+r+b', delete=False) - cs.fill_archive(stream=archive, kind=fileformat, subrepos=subrepos) - archive.close() + fd, _archive_name = tempfile.mkstemp(suffix='rcarchive') + with open(_archive_name, 'wb') as f: + cs.fill_archive(stream=f, kind=fileformat, subrepos=subrepos) + response.content_type = content_type response.content_disposition = 'attachment; filename=%s-%s%s' \ % (repo_name, revision[:12], ext) - response.content_length = str(os.path.getsize(archive.name)) + response.content_length = str(os.path.getsize(_archive_name)) def get_chunked_archive(tmpfile): while True: @@ -376,7 +377,7 @@ os.unlink(tmpfile.name) break yield data - return get_chunked_archive(tmpfile=open(archive.name,'rb')) + return get_chunked_archive(tmpfile=open(_archive_name, 'rb')) @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', 'repository.admin')