# HG changeset patch # User Marcin Lulek # Date 2019-02-12 09:14:15 # Node ID 41f317da9ec1d83d78e8fea625871927c8b75471 # Parent 7bc930538b4683fc02b84489710f692278eecd8b caches: allow cache disable for file tree diff --git a/rhodecode/apps/_base/__init__.py b/rhodecode/apps/_base/__init__.py --- a/rhodecode/apps/_base/__init__.py +++ b/rhodecode/apps/_base/__init__.py @@ -27,7 +27,7 @@ from pyramid.httpexceptions import HTTPF from rhodecode.lib import helpers as h, diffs from rhodecode.lib.utils2 import ( - StrictAttributeDict, safe_int, datetime_to_time, safe_unicode) + StrictAttributeDict, str2bool, safe_int, datetime_to_time, safe_unicode) from rhodecode.lib.vcs.exceptions import RepositoryRequirementError from rhodecode.model import repo from rhodecode.model import repo_group @@ -278,6 +278,13 @@ class RepoAppView(BaseAppView): settings = settings_model.get_general_settings() return settings.get(settings_key, default) + def get_recache_flag(self): + for flag_name in ['force_recache', 'force-recache', 'no-cache']: + flag_val = self.request.GET.get(flag_name) + if str2bool(flag_val): + return True + return False + class PathFilter(object): diff --git a/rhodecode/apps/repository/views/repo_files.py b/rhodecode/apps/repository/views/repo_files.py --- a/rhodecode/apps/repository/views/repo_files.py +++ b/rhodecode/apps/repository/views/repo_files.py @@ -229,10 +229,11 @@ class RepoFilesView(RepoAppView): self, c, commit_id, f_path, full_load=False): repo_id = self.db_repo.repo_id + force_recache = self.get_recache_flag() cache_seconds = safe_int( rhodecode.CONFIG.get('rc_cache.cache_repo.expiration_time')) - cache_on = cache_seconds > 0 + cache_on = not force_recache and cache_seconds > 0 log.debug( 'Computing FILE TREE for repo_id %s commit_id `%s` and path `%s`' 'with caching: %s[TTL: %ss]' % ( diff --git a/rhodecode/apps/repository/views/repo_pull_requests.py b/rhodecode/apps/repository/views/repo_pull_requests.py --- a/rhodecode/apps/repository/views/repo_pull_requests.py +++ b/rhodecode/apps/repository/views/repo_pull_requests.py @@ -137,13 +137,6 @@ class RepoPullRequestsView(RepoAppView, }) return data - def get_recache_flag(self): - for flag_name in ['force_recache', 'force-recache', 'no-cache']: - flag_val = self.request.GET.get(flag_name) - if str2bool(flag_val): - return True - return False - @LoginRequired() @HasRepoPermissionAnyDecorator( 'repository.read', 'repository.write', 'repository.admin')