archival: allowed using .tbz2 and .tgz extensions.
This commit is contained in:
parent
08e1196380
commit
30534413be
4 changed files with 17 additions and 14 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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' %
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue