##// END OF EJS Templates
archives: use a special name for non-hashed archives to fix caching issues.
milka -
r4647:ca5fbff8 default
parent child
Show More
@@ -542,6 +542,28 class TestRepositoryArchival(object):
542 for header in headers:
542 for header in headers:
543 assert header in response.headers.items()
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 @pytest.mark.parametrize('arch_ext',[
567 @pytest.mark.parametrize('arch_ext',[
546 'tar', 'rar', 'x', '..ax', '.zipz', 'tar.gz.tar'])
568 'tar', 'rar', 'x', '..ax', '.zipz', 'tar.gz.tar'])
547 def test_archival_wrong_ext(self, backend, arch_ext):
569 def test_archival_wrong_ext(self, backend, arch_ext):
@@ -325,17 +325,18 class RepoFilesView(RepoAppView):
325
325
326 return lf_enabled
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 # original backward compat name of archive
329 # original backward compat name of archive
330 clean_name = safe_str(db_repo_name.replace('/', '_'))
330 clean_name = safe_str(db_repo_name.replace('/', '_'))
331
331
332 # e.g vcsserver.zip
332 # e.g vcsserver.zip
333 # e.g vcsserver-abcdefgh.zip
333 # e.g vcsserver-abcdefgh.zip
334 # e.g vcsserver-abcdefgh-defghijk.zip
334 # e.g vcsserver-abcdefgh-defghijk.zip
335 archive_name = '{}{}{}{}{}'.format(
335 archive_name = '{}{}{}{}{}{}'.format(
336 clean_name,
336 clean_name,
337 '-sub' if subrepos else '',
337 '-sub' if subrepos else '',
338 commit_sha,
338 commit_sha,
339 '-{}'.format('plain') if not with_hash else '',
339 '-{}'.format(path_sha) if path_sha else '',
340 '-{}'.format(path_sha) if path_sha else '',
340 ext)
341 ext)
341 return archive_name
342 return archive_name
@@ -385,7 +386,7 class RepoFilesView(RepoAppView):
385 # used for cache etc
386 # used for cache etc
386 archive_name = self._get_archive_name(
387 archive_name = self._get_archive_name(
387 self.db_repo_name, commit_sha=short_sha, ext=ext, subrepos=subrepos,
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 if not with_hash:
391 if not with_hash:
391 short_sha = ''
392 short_sha = ''
@@ -394,7 +395,7 class RepoFilesView(RepoAppView):
394 # what end client gets served
395 # what end client gets served
395 response_archive_name = self._get_archive_name(
396 response_archive_name = self._get_archive_name(
396 self.db_repo_name, commit_sha=short_sha, ext=ext, subrepos=subrepos,
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 # remove extension from our archive directory name
399 # remove extension from our archive directory name
399 archive_dir_name = response_archive_name[:-len(ext)]
400 archive_dir_name = response_archive_name[:-len(ext)]
400
401
@@ -95,7 +95,8
95 var fname = selectedReference.raw_id + ext;
95 var fname = selectedReference.raw_id + ext;
96 var href = pyroutes.url('repo_archivefile', {
96 var href = pyroutes.url('repo_archivefile', {
97 'repo_name': templateContext.repo_name,
97 'repo_name': templateContext.repo_name,
98 'fname': fname
98 'fname': fname,
99 'with_hash': '1'
99 });
100 });
100 // set new label
101 // set new label
101 $(this).html(ico + ' {0}{1}'.format(escapeHtml(e.added.text), ext));
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