Mercurial > kallithea
changeset 2277:bb0309b4e1ee beta
fixed tests, and archival method
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 16 May 2012 01:20:52 +0200 |
parents | 8caaa9955f5e |
children | 24095abde696 |
files | rhodecode/controllers/files.py rhodecode/lib/vcs/backends/hg/changeset.py rhodecode/tests/functional/test_files.py |
diffstat | 3 files changed, 13 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/controllers/files.py Wed May 16 00:37:50 2012 +0200 +++ b/rhodecode/controllers/files.py Wed May 16 01:20:52 2012 +0200 @@ -360,9 +360,9 @@ except (ImproperArchiveTypeError, KeyError): return _('Unknown archive type') - archive = tempfile.NamedTemporaryFile(mode='w+r+b') + archive = tempfile.NamedTemporaryFile(mode='w+r+b', delete=False) cs.fill_archive(stream=archive, kind=fileformat, subrepos=subrepos) - + archive.close() response.content_type = content_type response.content_disposition = 'attachment; filename=%s-%s%s' \ % (repo_name, revision[:12], ext) @@ -373,9 +373,10 @@ data = tmpfile.read(16 * 1024) if not data: tmpfile.close() + os.unlink(tmpfile.name) break yield data - return get_chunked_archive(tmpfile=archive) + return get_chunked_archive(tmpfile=open(archive.name,'rb')) @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', 'repository.admin')
--- a/rhodecode/lib/vcs/backends/hg/changeset.py Wed May 16 00:37:50 2012 +0200 +++ b/rhodecode/lib/vcs/backends/hg/changeset.py Wed May 16 01:20:52 2012 +0200 @@ -260,9 +260,11 @@ elif prefix.strip() == '': raise VCSError("Prefix cannot be empty") + print stream.closed archival.archive(self.repository._repo, stream, self.raw_id, kind, prefix=prefix, subrepos=subrepos) - + print stream.closed + if stream.closed and hasattr(stream, 'name'): stream = open(stream.name, 'rb') elif hasattr(stream, 'mode') and 'r' not in stream.mode:
--- a/rhodecode/tests/functional/test_files.py Wed May 16 00:37:50 2012 +0200 +++ b/rhodecode/tests/functional/test_files.py Wed May 16 01:20:52 2012 +0200 @@ -190,10 +190,11 @@ self.log_user() for arch_ext, info in ARCHIVE_SPECS.items(): + short = '27cd5cce30c9%s' % arch_ext fname = '27cd5cce30c96924232dffcd24178a07ffeb5dfc%s' % arch_ext - filename = '%s-%s' % (HG_REPO, fname) - - response = self.app.get(url(controller='files', action='archivefile', + filename = '%s-%s' % (HG_REPO, short) + response = self.app.get(url(controller='files', + action='archivefile', repo_name=HG_REPO, fname=fname)) @@ -202,7 +203,8 @@ [('Pragma', 'no-cache'), ('Cache-Control', 'no-cache'), ('Content-Type', '%s; charset=utf-8' % info[0]), - ('Content-Disposition', 'attachment; filename=%s' % filename),] + ('Content-Disposition', 'attachment; filename=%s' % filename), + ] ) def test_archival_wrong_ext(self):