##// END OF EJS Templates
archival: allowed using .tbz2 and .tgz extensions.
marcink -
r3736:ab6407f1 new-ui
parent child Browse files
Show More
@@ -521,10 +521,10 b' class TestRepositoryArchival(object):'
521 def test_archival(self, backend):
521 def test_archival(self, backend):
522 backend.enable_downloads()
522 backend.enable_downloads()
523 commit = backend.repo.get_commit(commit_idx=173)
523 commit = backend.repo.get_commit(commit_idx=173)
524 for archive, info in settings.ARCHIVE_SPECS.items():
524 for a_type, content_type, extension in settings.ARCHIVE_SPECS:
525 mime_type, arch_ext = info
525
526 short = commit.short_id + arch_ext
526 short = commit.short_id + extension
527 fname = commit.raw_id + arch_ext
527 fname = commit.raw_id + extension
528 filename = '%s-%s' % (backend.repo_name, short)
528 filename = '%s-%s' % (backend.repo_name, short)
529 response = self.app.get(
529 response = self.app.get(
530 route_path('repo_archivefile',
530 route_path('repo_archivefile',
@@ -534,7 +534,7 b' class TestRepositoryArchival(object):'
534 assert response.status == '200 OK'
534 assert response.status == '200 OK'
535 headers = [
535 headers = [
536 ('Content-Disposition', 'attachment; filename=%s' % filename),
536 ('Content-Disposition', 'attachment; filename=%s' % filename),
537 ('Content-Type', '%s' % mime_type),
537 ('Content-Type', '%s' % content_type),
538 ]
538 ]
539
539
540 for header in headers:
540 for header in headers:
@@ -260,8 +260,7 b' class RepoFilesView(RepoAppView):'
260 fileformat = None
260 fileformat = None
261 ext = None
261 ext = None
262 content_type = None
262 content_type = None
263 for a_type, ext_data in settings.ARCHIVE_SPECS.items():
263 for a_type, content_type, extension in settings.ARCHIVE_SPECS:
264 content_type, extension = ext_data
265
264
266 if fname.endswith(extension):
265 if fname.endswith(extension):
267 fileformat = a_type
266 fileformat = a_type
@@ -1111,7 +1111,7 b' class BaseCommit(object):'
1111
1111
1112 :raise VCSError: If prefix has a problem.
1112 :raise VCSError: If prefix has a problem.
1113 """
1113 """
1114 allowed_kinds = settings.ARCHIVE_SPECS.keys()
1114 allowed_kinds = [x[0] for x in settings.ARCHIVE_SPECS]
1115 if kind not in allowed_kinds:
1115 if kind not in allowed_kinds:
1116 raise ImproperArchiveTypeError(
1116 raise ImproperArchiveTypeError(
1117 'Archive kind (%s) not supported use one of %s' %
1117 'Archive kind (%s) not supported use one of %s' %
@@ -42,12 +42,16 b' BACKENDS = {'
42 'svn': 'rhodecode.lib.vcs.backends.svn.SubversionRepository',
42 'svn': 'rhodecode.lib.vcs.backends.svn.SubversionRepository',
43 }
43 }
44
44
45 # TODO: Remove once controllers/files.py is adjusted
45
46 ARCHIVE_SPECS = {
46 ARCHIVE_SPECS = [
47 'tbz2': ('application/x-bzip2', '.tar.bz2'),
47 ('tbz2', 'application/x-bzip2', 'tbz2'),
48 'tgz': ('application/x-gzip', '.tar.gz'),
48 ('tbz2', 'application/x-bzip2', '.tar.bz2'),
49 'zip': ('application/zip', '.zip'),
49
50 }
50 ('tgz', 'application/x-gzip', '.tgz'),
51 ('tgz', 'application/x-gzip', '.tar.gz'),
52
53 ('zip', 'application/zip', '.zip'),
54 ]
51
55
52 HOOKS_PROTOCOL = None
56 HOOKS_PROTOCOL = None
53 HOOKS_DIRECT_CALLS = False
57 HOOKS_DIRECT_CALLS = False
General Comments 0
You need to be logged in to leave comments. Login now