From 8c12bc34c3f913b0edaea407d67ac549d6a2143a Mon Sep 17 00:00:00 2001 From: Milka Kuzminski Date: Thu, 11 Mar 2021 10:28:52 +0100 Subject: [PATCH] archives: if implicit ref name was used to obtain archive, redirect to explicit commit sha so we can have the proper caching for references names. --- rhodecode/apps/repository/views/repo_files.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rhodecode/apps/repository/views/repo_files.py b/rhodecode/apps/repository/views/repo_files.py index be093aba..a2ae4e21 100644 --- a/rhodecode/apps/repository/views/repo_files.py +++ b/rhodecode/apps/repository/views/repo_files.py @@ -373,6 +373,11 @@ class RepoFilesView(RepoAppView): except EmptyRepositoryError: return Response(_('Empty repository')) + # we used a ref, or a shorter version, lets redirect client ot use explicit hash + if commit_id != commit.raw_id: + fname='{}{}'.format(commit.raw_id, ext) + raise HTTPFound(self.request.current_route_path(fname=fname)) + try: at_path = commit.get_node(at_path).path or default_at_path except Exception: @@ -405,9 +410,10 @@ class RepoFilesView(RepoAppView): cached_archive_path = None if archive_cache_enabled: - # check if we it's ok to write + # check if we it's ok to write, and re-create the archive cache if not os.path.isdir(CONFIG['archive_cache_dir']): os.makedirs(CONFIG['archive_cache_dir']) + cached_archive_path = os.path.join( CONFIG['archive_cache_dir'], archive_name) if os.path.isfile(cached_archive_path):