# HG changeset patch # User Marcin Kuzminski # Date 2019-06-06 19:05:45 # Node ID ab6407f1d36dcb48361dd20dc1b5761a64fb77ed # Parent 26e4a4fcb4504c69074b0d43c0dd087e50a1ca21 archival: allowed using .tbz2 and .tgz extensions. diff --git a/rhodecode/apps/repository/tests/test_repo_files.py b/rhodecode/apps/repository/tests/test_repo_files.py --- a/rhodecode/apps/repository/tests/test_repo_files.py +++ b/rhodecode/apps/repository/tests/test_repo_files.py @@ -521,10 +521,10 @@ class TestRepositoryArchival(object): def test_archival(self, backend): backend.enable_downloads() commit = backend.repo.get_commit(commit_idx=173) - for archive, info in settings.ARCHIVE_SPECS.items(): - mime_type, arch_ext = info - short = commit.short_id + arch_ext - fname = commit.raw_id + arch_ext + for a_type, content_type, extension in settings.ARCHIVE_SPECS: + + short = commit.short_id + extension + fname = commit.raw_id + extension filename = '%s-%s' % (backend.repo_name, short) response = self.app.get( route_path('repo_archivefile', @@ -534,7 +534,7 @@ class TestRepositoryArchival(object): assert response.status == '200 OK' headers = [ ('Content-Disposition', 'attachment; filename=%s' % filename), - ('Content-Type', '%s' % mime_type), + ('Content-Type', '%s' % content_type), ] for header in headers: diff --git a/rhodecode/apps/repository/views/repo_files.py b/rhodecode/apps/repository/views/repo_files.py --- a/rhodecode/apps/repository/views/repo_files.py +++ b/rhodecode/apps/repository/views/repo_files.py @@ -260,8 +260,7 @@ class RepoFilesView(RepoAppView): fileformat = None ext = None content_type = None - for a_type, ext_data in settings.ARCHIVE_SPECS.items(): - content_type, extension = ext_data + for a_type, content_type, extension in settings.ARCHIVE_SPECS: if fname.endswith(extension): fileformat = a_type diff --git a/rhodecode/lib/vcs/backends/base.py b/rhodecode/lib/vcs/backends/base.py --- a/rhodecode/lib/vcs/backends/base.py +++ b/rhodecode/lib/vcs/backends/base.py @@ -1111,7 +1111,7 @@ class BaseCommit(object): :raise VCSError: If prefix has a problem. """ - allowed_kinds = settings.ARCHIVE_SPECS.keys() + allowed_kinds = [x[0] for x in settings.ARCHIVE_SPECS] if kind not in allowed_kinds: raise ImproperArchiveTypeError( 'Archive kind (%s) not supported use one of %s' % diff --git a/rhodecode/lib/vcs/conf/settings.py b/rhodecode/lib/vcs/conf/settings.py --- a/rhodecode/lib/vcs/conf/settings.py +++ b/rhodecode/lib/vcs/conf/settings.py @@ -42,12 +42,16 @@ BACKENDS = { 'svn': 'rhodecode.lib.vcs.backends.svn.SubversionRepository', } -# TODO: Remove once controllers/files.py is adjusted -ARCHIVE_SPECS = { - 'tbz2': ('application/x-bzip2', '.tar.bz2'), - 'tgz': ('application/x-gzip', '.tar.gz'), - 'zip': ('application/zip', '.zip'), -} + +ARCHIVE_SPECS = [ + ('tbz2', 'application/x-bzip2', 'tbz2'), + ('tbz2', 'application/x-bzip2', '.tar.bz2'), + + ('tgz', 'application/x-gzip', '.tgz'), + ('tgz', 'application/x-gzip', '.tar.gz'), + + ('zip', 'application/zip', '.zip'), +] HOOKS_PROTOCOL = None HOOKS_DIRECT_CALLS = False