diff --git a/rhodecode/apps/repository/views/repo_caches.py b/rhodecode/apps/repository/views/repo_caches.py --- a/rhodecode/apps/repository/views/repo_caches.py +++ b/rhodecode/apps/repository/views/repo_caches.py @@ -18,6 +18,7 @@ # RhodeCode Enterprise Edition, including its added features, Support services, # and proprietary license terms, please see https://rhodecode.com/licenses/ +import os import logging from pyramid.httpexceptions import HTTPFound @@ -27,6 +28,7 @@ from rhodecode.apps._base import RepoApp from rhodecode.lib.auth import ( LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired) from rhodecode.lib import helpers as h +from rhodecode.lib import system_info from rhodecode.model.meta import Session from rhodecode.model.scm import ScmModel @@ -36,8 +38,6 @@ log = logging.getLogger(__name__) class RepoCachesView(RepoAppView): def load_default_context(self): c = self._get_local_tmpl_context() - - return c @LoginRequired() @@ -48,6 +48,11 @@ class RepoCachesView(RepoAppView): def repo_caches(self): c = self.load_default_context() c.active = 'caches' + cached_diffs_dir = c.rhodecode_db_repo.cached_diffs_dir + c.cached_diff_count = len(c.rhodecode_db_repo.cached_diffs()) + c.cached_diff_size = 0 + if os.path.isdir(cached_diffs_dir): + c.cached_diff_size = system_info.get_storage_size(cached_diffs_dir) return self._get_template_context(c) diff --git a/rhodecode/lib/vcs/backends/base.py b/rhodecode/lib/vcs/backends/base.py --- a/rhodecode/lib/vcs/backends/base.py +++ b/rhodecode/lib/vcs/backends/base.py @@ -206,10 +206,8 @@ class BaseRepository(object): def __ne__(self, other): return not self.__eq__(other) - def get_create_shadow_cache_pr_path(self, repo): - path = os.path.join( - os.path.dirname(self.path), - '.__shadow_diff_cache_repo_{}/'.format(repo.repo_id)) + def get_create_shadow_cache_pr_path(self, db_repo): + path = db_repo.cached_diffs_dir if not os.path.exists(path): os.makedirs(path, 0755) return path diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -1859,6 +1859,19 @@ class Repository(Base, BaseModel): .order_by(CacheKey.cache_key)\ .all() + @property + def cached_diffs_dir(self): + path = self.repo_full_path + return os.path.join( + os.path.dirname(path), + '.__shadow_diff_cache_repo_{}'.format(self.repo_id)) + + def cached_diffs(self): + diff_cache_dir = self.cached_diffs_dir + if os.path.isdir(diff_cache_dir): + return os.listdir(diff_cache_dir) + return [] + def get_new_name(self, repo_name): """ returns new full repository name based on assigned group and new new diff --git a/rhodecode/templates/admin/repos/repo_edit_caches.mako b/rhodecode/templates/admin/repos/repo_edit_caches.mako --- a/rhodecode/templates/admin/repos/repo_edit_caches.mako +++ b/rhodecode/templates/admin/repos/repo_edit_caches.mako @@ -51,3 +51,22 @@ + + +
+
+

${_('Diff Caches')}

+
+
+ + + + + + + + + +
${_('Cached diff files')}:${c.cached_diff_count}
${_('Cached diff size')}:${h.format_byte_size(c.cached_diff_size)}
+
+