# HG changeset patch # User Marcin Kuzminski # Date 2012-05-15 21:27:52 # Node ID c9dc3cd9ce14a33c411400c0f0e38dee778fc7de # Parent 6eaa2395a80e832e820e384ff44057c85e6a589f # Parent f1467dfcf093dd1b5b6aeabdfb8430068eb6e573 merge with beta diff --git a/README.rst b/README.rst --- a/README.rst +++ b/README.rst @@ -15,7 +15,7 @@ RhodeCode is similar in some respects to however RhodeCode can be run as standalone hosted application on your own server. It is open source and donation ware and focuses more on providing a customized, self administered interface for Mercurial_ and GIT_ repositories. -RhodeCode works on *nix systems and Windows it is powered by a vcs_ library +RhodeCode works on \*nix systems and Windows it is powered by a vcs_ library that Lukasz Balcerzak and Marcin Kuzminski created to handle multiple different version control systems. diff --git a/rhodecode/controllers/files.py b/rhodecode/controllers/files.py --- a/rhodecode/controllers/files.py +++ b/rhodecode/controllers/files.py @@ -26,6 +26,7 @@ import os import logging import traceback +import tempfile from pylons import request, response, tmpl_context as c, url from pylons.i18n.translation import _ @@ -359,25 +360,22 @@ class FilesController(BaseRepoController except (ImproperArchiveTypeError, KeyError): return _('Unknown archive type') + archive = tempfile.NamedTemporaryFile(mode='w+r+b') + cs.fill_archive(stream=archive, kind=fileformat, subrepos=subrepos) + response.content_type = content_type response.content_disposition = 'attachment; filename=%s-%s%s' \ - % (repo_name, revision, ext) - - import tempfile - archive = tempfile.mkstemp()[1] - t = open(archive, 'wb') - cs.fill_archive(stream=t, kind=fileformat, subrepos=subrepos) + % (repo_name, revision[:12], ext) + response.content_length = str(os.path.getsize(archive.name)) - def get_chunked_archive(archive): - stream = open(archive, 'rb') + def get_chunked_archive(tmpfile): while True: - data = stream.read(4096) + data = tmpfile.read(16 * 1024) if not data: - os.remove(archive) + tmpfile.close() break yield data - - return get_chunked_archive(archive) + return get_chunked_archive(tmpfile=archive) @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', 'repository.admin') diff --git a/rhodecode/lib/vcs/backends/hg/changeset.py b/rhodecode/lib/vcs/backends/hg/changeset.py --- a/rhodecode/lib/vcs/backends/hg/changeset.py +++ b/rhodecode/lib/vcs/backends/hg/changeset.py @@ -263,8 +263,6 @@ class MercurialChangeset(BaseChangeset): archival.archive(self.repository._repo, stream, self.raw_id, kind, prefix=prefix, subrepos=subrepos) - #stream.close() - if stream.closed and hasattr(stream, 'name'): stream = open(stream.name, 'rb') elif hasattr(stream, 'mode') and 'r' not in stream.mode: