Show More
@@ -1,80 +1,80 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | # Copyright (C) 2011-2018 RhodeCode GmbH |
|
4 | 4 | # |
|
5 | 5 | # This program is free software: you can redistribute it and/or modify |
|
6 | 6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
7 | 7 | # (only), as published by the Free Software Foundation. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU Affero General Public License |
|
15 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | 16 | # |
|
17 | 17 | # This program is dual-licensed. If you wish to learn more about the |
|
18 | 18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
19 | 19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
20 | 20 | |
|
21 | 21 | import os |
|
22 | 22 | import logging |
|
23 | 23 | |
|
24 | 24 | from pyramid.httpexceptions import HTTPFound |
|
25 | 25 | from pyramid.view import view_config |
|
26 | 26 | |
|
27 | 27 | from rhodecode.apps._base import RepoAppView |
|
28 | 28 | from rhodecode.lib.auth import ( |
|
29 | 29 | LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired) |
|
30 | 30 | from rhodecode.lib import helpers as h |
|
31 | 31 | from rhodecode.lib import system_info |
|
32 | 32 | from rhodecode.model.meta import Session |
|
33 | 33 | from rhodecode.model.scm import ScmModel |
|
34 | 34 | |
|
35 | 35 | log = logging.getLogger(__name__) |
|
36 | 36 | |
|
37 | 37 | |
|
38 | 38 | class RepoCachesView(RepoAppView): |
|
39 | 39 | def load_default_context(self): |
|
40 | 40 | c = self._get_local_tmpl_context() |
|
41 | 41 | return c |
|
42 | 42 | |
|
43 | 43 | @LoginRequired() |
|
44 | 44 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
45 | 45 | @view_config( |
|
46 | 46 | route_name='edit_repo_caches', request_method='GET', |
|
47 | 47 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') |
|
48 | 48 | def repo_caches(self): |
|
49 | 49 | c = self.load_default_context() |
|
50 | 50 | c.active = 'caches' |
|
51 | 51 | cached_diffs_dir = c.rhodecode_db_repo.cached_diffs_dir |
|
52 | 52 | c.cached_diff_count = len(c.rhodecode_db_repo.cached_diffs()) |
|
53 | 53 | c.cached_diff_size = 0 |
|
54 | 54 | if os.path.isdir(cached_diffs_dir): |
|
55 | 55 | c.cached_diff_size = system_info.get_storage_size(cached_diffs_dir) |
|
56 | ||
|
56 | c.shadow_repos = c.rhodecode_db_repo.shadow_repos() | |
|
57 | 57 | return self._get_template_context(c) |
|
58 | 58 | |
|
59 | 59 | @LoginRequired() |
|
60 | 60 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
61 | 61 | @CSRFRequired() |
|
62 | 62 | @view_config( |
|
63 | 63 | route_name='edit_repo_caches', request_method='POST') |
|
64 | 64 | def repo_caches_purge(self): |
|
65 | 65 | _ = self.request.translate |
|
66 | 66 | c = self.load_default_context() |
|
67 | 67 | c.active = 'caches' |
|
68 | 68 | |
|
69 | 69 | try: |
|
70 | 70 | ScmModel().mark_for_invalidation(self.db_repo_name, delete=True) |
|
71 | 71 | Session().commit() |
|
72 | 72 | h.flash(_('Cache invalidation successful'), |
|
73 | 73 | category='success') |
|
74 | 74 | except Exception: |
|
75 | 75 | log.exception("Exception during cache invalidation") |
|
76 | 76 | h.flash(_('An error occurred during cache invalidation'), |
|
77 | 77 | category='error') |
|
78 | 78 | |
|
79 | 79 | raise HTTPFound(h.route_path( |
|
80 | 80 | 'edit_repo_caches', repo_name=self.db_repo_name)) No newline at end of file |
@@ -1,76 +1,98 b'' | |||
|
1 | 1 | <div class="panel panel-default"> |
|
2 | 2 | <div class="panel-heading"> |
|
3 | 3 | <h3 class="panel-title">${_('Invalidate Cache for Repository')}</h3> |
|
4 | 4 | </div> |
|
5 | 5 | <div class="panel-body"> |
|
6 | 6 | |
|
7 | 7 | <h4>${_('Manually invalidate the repository cache. On the next access a repository cache will be recreated.')}</h4> |
|
8 | 8 | |
|
9 | 9 | <p> |
|
10 | 10 | ${_('Cache purge can be automated by such api call. Can be called periodically in crontab etc.')} |
|
11 | 11 | <br/> |
|
12 | 12 | <code> |
|
13 | 13 | ${h.api_call_example(method='invalidate_cache', args={"repoid": c.rhodecode_db_repo.repo_name})} |
|
14 | 14 | </code> |
|
15 | 15 | </p> |
|
16 | 16 | |
|
17 | 17 | ${h.secure_form(h.route_path('edit_repo_caches', repo_name=c.repo_name), request=request)} |
|
18 | 18 | <div class="form"> |
|
19 | 19 | <div class="fields"> |
|
20 | 20 | ${h.submit('reset_cache_%s' % c.rhodecode_db_repo.repo_name,_('Invalidate repository cache'),class_="btn btn-small",onclick="return confirm('"+_('Confirm to invalidate repository cache')+"');")} |
|
21 | 21 | </div> |
|
22 | 22 | </div> |
|
23 | 23 | ${h.end_form()} |
|
24 | 24 | |
|
25 | 25 | </div> |
|
26 | 26 | </div> |
|
27 | 27 | |
|
28 | 28 | |
|
29 | 29 | <div class="panel panel-default"> |
|
30 | 30 | <div class="panel-heading"> |
|
31 | 31 | <h3 class="panel-title"> |
|
32 | 32 | ${(_ungettext('List of repository caches (%(count)s entry)', 'List of repository caches (%(count)s entries)' ,len(c.rhodecode_db_repo.cache_keys)) % {'count': len(c.rhodecode_db_repo.cache_keys)})} |
|
33 | 33 | </h3> |
|
34 | 34 | </div> |
|
35 | 35 | <div class="panel-body"> |
|
36 | 36 | <div class="field" > |
|
37 | 37 | <table class="rctable edit_cache"> |
|
38 | 38 | <tr> |
|
39 | 39 | <th>${_('Prefix')}</th> |
|
40 | 40 | <th>${_('Key')}</th> |
|
41 | 41 | <th>${_('Active')}</th> |
|
42 | 42 | </tr> |
|
43 | 43 | %for cache in c.rhodecode_db_repo.cache_keys: |
|
44 | 44 | <tr> |
|
45 | 45 | <td class="td-prefix">${cache.get_prefix() or '-'}</td> |
|
46 | 46 | <td class="td-cachekey">${cache.cache_key}</td> |
|
47 | 47 | <td class="td-active">${h.bool2icon(cache.cache_active)}</td> |
|
48 | 48 | </tr> |
|
49 | 49 | %endfor |
|
50 | 50 | </table> |
|
51 | 51 | </div> |
|
52 | 52 | </div> |
|
53 | 53 | </div> |
|
54 | 54 | |
|
55 | <div class="panel panel-default"> | |
|
56 | <div class="panel-heading"> | |
|
57 | <h3 class="panel-title">${_('Shadow Repositories')}</h3> | |
|
58 | </div> | |
|
59 | <div class="panel-body"> | |
|
60 | <table class="rctable edit_cache"> | |
|
61 | % if c.shadow_repos: | |
|
62 | % for shadow_repo in c.shadow_repos: | |
|
63 | <tr> | |
|
64 | <td>${shadow_repo}</td> | |
|
65 | </tr> | |
|
66 | % endfor | |
|
67 | % else: | |
|
68 | <tr> | |
|
69 | <td>${_('No Shadow repositories exist for this repository.')}</td> | |
|
70 | </tr> | |
|
71 | % endif | |
|
72 | ||
|
73 | </table> | |
|
74 | </div> | |
|
75 | </div> | |
|
76 | ||
|
55 | 77 | |
|
56 | 78 | <div class="panel panel-default"> |
|
57 | 79 | <div class="panel-heading"> |
|
58 | 80 | <h3 class="panel-title">${_('Diff Caches')}</h3> |
|
59 | 81 | </div> |
|
60 | 82 | <div class="panel-body"> |
|
61 | 83 | <table class="rctable edit_cache"> |
|
62 | 84 | <tr> |
|
63 | 85 | <td>${_('Cached diff name')}:</td> |
|
64 | 86 | <td>${c.rhodecode_db_repo.cached_diffs_relative_dir}</td> |
|
65 | 87 | </tr> |
|
66 | 88 | <tr> |
|
67 | 89 | <td>${_('Cached diff files')}:</td> |
|
68 | 90 | <td>${c.cached_diff_count}</td> |
|
69 | 91 | </tr> |
|
70 | 92 | <tr> |
|
71 | 93 | <td>${_('Cached diff size')}:</td> |
|
72 | 94 | <td>${h.format_byte_size(c.cached_diff_size)}</td> |
|
73 | 95 | </tr> |
|
74 | 96 | </table> |
|
75 | 97 | </div> |
|
76 | 98 | </div> |
General Comments 0
You need to be logged in to leave comments.
Login now