files: ensure caches are invalidated for file viewer when name, or parent group changes
marcink -
r4349:baeed9e1 default
Not Reviewed
Show More
Add another comment
TODOs: 0 unresolved 0 Resolved
COMMENTS: 0 General 0 Inline
@@ -261,20 +261,19 class RepoFilesView(RepoAppView):
261 cache_namespace_uid = 'cache_repo.{}'.format(repo_id)
261 cache_namespace_uid = 'cache_repo.{}'.format(repo_id)
262 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
262 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
263
263
264 @region.conditional_cache_on_arguments(namespace=cache_namespace_uid,
264 @region.conditional_cache_on_arguments(namespace=cache_namespace_uid, condition=cache_on)
265 condition=cache_on)
265 def compute_file_tree(ver, _name_hash, _repo_id, _commit_id, _f_path, _full_load, _at_rev):
266 def compute_file_tree(ver, repo_id, commit_id, f_path, full_load, at_rev):
267 log.debug('Generating cached file tree at ver:%s for repo_id: %s, %s, %s',
266 log.debug('Generating cached file tree at ver:%s for repo_id: %s, %s, %s',
268 ver, repo_id, commit_id, f_path)
267 ver, _repo_id, _commit_id, _f_path)
269
268
270 c.full_load = full_load
269 c.full_load = _full_load
271 return render(
270 return render(
272 'rhodecode:templates/files/files_browser_tree.mako',
271 'rhodecode:templates/files/files_browser_tree.mako',
273 self._get_template_context(c), self.request, at_rev)
272 self._get_template_context(c), self.request, _at_rev)
274
273
275 return compute_file_tree(
274 return compute_file_tree(
276 rc_cache.FILE_TREE_CACHE_VER, self.db_repo.repo_id, commit_id,
275 rc_cache.FILE_TREE_CACHE_VER, self.db_repo.repo_name_hash,
277 f_path, full_load, at_rev)
276 self.db_repo.repo_id, commit_id, f_path, full_load, at_rev)
278
277
279 def _get_archive_spec(self, fname):
278 def _get_archive_spec(self, fname):
280 log.debug('Detecting archive spec for: `%s`', fname)
279 log.debug('Detecting archive spec for: `%s`', fname)
@@ -914,13 +913,12 class RepoFilesView(RepoAppView):
914 cache_namespace_uid = 'cache_repo.{}'.format(repo_id)
913 cache_namespace_uid = 'cache_repo.{}'.format(repo_id)
915 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
914 region = rc_cache.get_or_create_region('cache_repo', cache_namespace_uid)
916
915
917 @region.conditional_cache_on_arguments(namespace=cache_namespace_uid,
916 @region.conditional_cache_on_arguments(namespace=cache_namespace_uid, condition=cache_on)
918 condition=cache_on)
917 def compute_file_search(_name_hash, _repo_id, _commit_id, _f_path):
919 def compute_file_search(repo_id, commit_id, f_path):
920 log.debug('Generating cached nodelist for repo_id:%s, %s, %s',
918 log.debug('Generating cached nodelist for repo_id:%s, %s, %s',
921 repo_id, commit_id, f_path)
919 _repo_id, commit_id, f_path)
922 try:
920 try:
923 _d, _f = ScmModel().get_quick_filter_nodes(repo_name, commit_id, f_path)
921 _d, _f = ScmModel().get_quick_filter_nodes(repo_name, _commit_id, _f_path)
924 except (RepositoryError, CommitDoesNotExistError, Exception) as e:
922 except (RepositoryError, CommitDoesNotExistError, Exception) as e:
925 log.exception(safe_str(e))
923 log.exception(safe_str(e))
926 h.flash(safe_str(h.escape(e)), category='error')
924 h.flash(safe_str(h.escape(e)), category='error')
@@ -930,7 +928,8 class RepoFilesView(RepoAppView):
930
928
931 return _d + _f
929 return _d + _f
932
930
933 result = compute_file_search(self.db_repo.repo_id, commit_id, f_path)
931 result = compute_file_search(self.db_repo.repo_name_hash, self.db_repo.repo_id,
932 commit_id, f_path)
934 return filter(lambda n: self.path_filter.path_access_allowed(n['name']), result)
933 return filter(lambda n: self.path_filter.path_access_allowed(n['name']), result)
935
934
936 @LoginRequired()
935 @LoginRequired()
Comments 0
You need to be logged in to leave comments. Login now