Show More
@@ -542,6 +542,28 b' class TestRepositoryArchival(object):' | |||
|
542 | 542 | for header in headers: |
|
543 | 543 | assert header in response.headers.items() |
|
544 | 544 | |
|
545 | def test_archival_no_hash(self, backend): | |
|
546 | backend.enable_downloads() | |
|
547 | commit = backend.repo.get_commit(commit_idx=173) | |
|
548 | for a_type, content_type, extension in settings.ARCHIVE_SPECS: | |
|
549 | ||
|
550 | short = 'plain' + extension | |
|
551 | fname = commit.raw_id + extension | |
|
552 | filename = '%s-%s' % (backend.repo_name, short) | |
|
553 | response = self.app.get( | |
|
554 | route_path('repo_archivefile', | |
|
555 | repo_name=backend.repo_name, | |
|
556 | fname=fname, params={'with_hash': 0})) | |
|
557 | ||
|
558 | assert response.status == '200 OK' | |
|
559 | headers = [ | |
|
560 | ('Content-Disposition', 'attachment; filename=%s' % filename), | |
|
561 | ('Content-Type', '%s' % content_type), | |
|
562 | ] | |
|
563 | ||
|
564 | for header in headers: | |
|
565 | assert header in response.headers.items() | |
|
566 | ||
|
545 | 567 | @pytest.mark.parametrize('arch_ext',[ |
|
546 | 568 | 'tar', 'rar', 'x', '..ax', '.zipz', 'tar.gz.tar']) |
|
547 | 569 | def test_archival_wrong_ext(self, backend, arch_ext): |
@@ -325,17 +325,18 b' class RepoFilesView(RepoAppView):' | |||
|
325 | 325 | |
|
326 | 326 | return lf_enabled |
|
327 | 327 | |
|
328 | def _get_archive_name(self, db_repo_name, commit_sha, ext, subrepos=False, path_sha=''): | |
|
328 | def _get_archive_name(self, db_repo_name, commit_sha, ext, subrepos=False, path_sha='', with_hash=True): | |
|
329 | 329 | # original backward compat name of archive |
|
330 | 330 | clean_name = safe_str(db_repo_name.replace('/', '_')) |
|
331 | 331 | |
|
332 | 332 | # e.g vcsserver.zip |
|
333 | 333 | # e.g vcsserver-abcdefgh.zip |
|
334 | 334 | # e.g vcsserver-abcdefgh-defghijk.zip |
|
335 | archive_name = '{}{}{}{}{}'.format( | |
|
335 | archive_name = '{}{}{}{}{}{}'.format( | |
|
336 | 336 | clean_name, |
|
337 | 337 | '-sub' if subrepos else '', |
|
338 | 338 | commit_sha, |
|
339 | '-{}'.format('plain') if not with_hash else '', | |
|
339 | 340 | '-{}'.format(path_sha) if path_sha else '', |
|
340 | 341 | ext) |
|
341 | 342 | return archive_name |
@@ -385,7 +386,7 b' class RepoFilesView(RepoAppView):' | |||
|
385 | 386 | # used for cache etc |
|
386 | 387 | archive_name = self._get_archive_name( |
|
387 | 388 | self.db_repo_name, commit_sha=short_sha, ext=ext, subrepos=subrepos, |
|
388 | path_sha=path_sha) | |
|
389 | path_sha=path_sha, with_hash=with_hash) | |
|
389 | 390 | |
|
390 | 391 | if not with_hash: |
|
391 | 392 | short_sha = '' |
@@ -394,7 +395,7 b' class RepoFilesView(RepoAppView):' | |||
|
394 | 395 | # what end client gets served |
|
395 | 396 | response_archive_name = self._get_archive_name( |
|
396 | 397 | self.db_repo_name, commit_sha=short_sha, ext=ext, subrepos=subrepos, |
|
397 | path_sha=path_sha) | |
|
398 | path_sha=path_sha, with_hash=with_hash) | |
|
398 | 399 | # remove extension from our archive directory name |
|
399 | 400 | archive_dir_name = response_archive_name[:-len(ext)] |
|
400 | 401 |
@@ -95,7 +95,8 b'' | |||
|
95 | 95 | var fname = selectedReference.raw_id + ext; |
|
96 | 96 | var href = pyroutes.url('repo_archivefile', { |
|
97 | 97 | 'repo_name': templateContext.repo_name, |
|
98 | 'fname': fname | |
|
98 | 'fname': fname, | |
|
99 | 'with_hash': '1' | |
|
99 | 100 | }); |
|
100 | 101 | // set new label |
|
101 | 102 | $(this).html(ico + ' {0}{1}'.format(escapeHtml(e.added.text), ext)); |
General Comments 0
You need to be logged in to leave comments.
Login now