Changeset - bb0309b4e1ee
[Not reviewed]
beta
0 3 0
Marcin Kuzminski - 14 years ago 2012-05-16 01:20:52
marcin@python-works.com
fixed tests, and archival method
3 files changed with 13 insertions and 8 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/files.py
Show inline comments
 
@@ -360,9 +360,9 @@ class FilesController(BaseRepoController
 
        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 @@ class FilesController(BaseRepoController
 
                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')
rhodecode/lib/vcs/backends/hg/changeset.py
Show inline comments
 
@@ -260,9 +260,11 @@ class MercurialChangeset(BaseChangeset):
 
        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:
rhodecode/tests/functional/test_files.py
Show inline comments
 
@@ -190,10 +190,11 @@ class TestFilesController(TestController
 
        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 @@ class TestFilesController(TestController
 
             [('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):
0 comments (0 inline, 0 general)