Show More
@@ -40,7 +40,7 b' from rhodecode.lib.auth import LoginRequ' | |||||
40 | HasPermissionAnyDecorator, HasRepoPermissionAllDecorator, NotAnonymous,\ |
|
40 | HasPermissionAnyDecorator, HasRepoPermissionAllDecorator, NotAnonymous,\ | |
41 | HasPermissionAny, HasReposGroupPermissionAny, HasRepoPermissionAnyDecorator |
|
41 | HasPermissionAny, HasReposGroupPermissionAny, HasRepoPermissionAnyDecorator | |
42 | from rhodecode.lib.base import BaseRepoController, render |
|
42 | from rhodecode.lib.base import BaseRepoController, render | |
43 |
from rhodecode.lib.utils import |
|
43 | from rhodecode.lib.utils import action_logger, repo_name_slug | |
44 | from rhodecode.lib.helpers import get_token |
|
44 | from rhodecode.lib.helpers import get_token | |
45 | from rhodecode.model.meta import Session |
|
45 | from rhodecode.model.meta import Session | |
46 | from rhodecode.model.db import User, Repository, UserFollowing, RepoGroup,\ |
|
46 | from rhodecode.model.db import User, Repository, UserFollowing, RepoGroup,\ | |
@@ -262,7 +262,7 b' class ReposController(BaseRepoController' | |||||
262 | try: |
|
262 | try: | |
263 | form_result = _form.to_python(dict(request.POST)) |
|
263 | form_result = _form.to_python(dict(request.POST)) | |
264 | repo = repo_model.update(repo_name, **form_result) |
|
264 | repo = repo_model.update(repo_name, **form_result) | |
265 | invalidate_cache('get_repo_cached_%s' % repo_name) |
|
265 | ScmModel().mark_for_invalidation(repo_name) | |
266 | h.flash(_('Repository %s updated successfully') % repo_name, |
|
266 | h.flash(_('Repository %s updated successfully') % repo_name, | |
267 | category='success') |
|
267 | category='success') | |
268 | changed_name = repo.repo_name |
|
268 | changed_name = repo.repo_name | |
@@ -315,7 +315,7 b' class ReposController(BaseRepoController' | |||||
315 | repo_model.delete(repo, forks=handle_forks) |
|
315 | repo_model.delete(repo, forks=handle_forks) | |
316 | action_logger(self.rhodecode_user, 'admin_deleted_repo', |
|
316 | action_logger(self.rhodecode_user, 'admin_deleted_repo', | |
317 | repo_name, self.ip_addr, self.sa) |
|
317 | repo_name, self.ip_addr, self.sa) | |
318 | invalidate_cache('get_repo_cached_%s' % repo_name) |
|
318 | ScmModel().mark_for_invalidation(repo_name) | |
319 | h.flash(_('Deleted repository %s') % repo_name, category='success') |
|
319 | h.flash(_('Deleted repository %s') % repo_name, category='success') | |
320 | Session().commit() |
|
320 | Session().commit() | |
321 | except AttachedForksError: |
|
321 | except AttachedForksError: |
@@ -41,8 +41,8 b' from rhodecode.lib.auth import LoginRequ' | |||||
41 | HasReposGroupPermissionAll, HasReposGroupPermissionAny, AuthUser |
|
41 | HasReposGroupPermissionAll, HasReposGroupPermissionAny, AuthUser | |
42 | from rhodecode.lib.base import BaseController, render |
|
42 | from rhodecode.lib.base import BaseController, render | |
43 | from rhodecode.lib.celerylib import tasks, run_task |
|
43 | from rhodecode.lib.celerylib import tasks, run_task | |
44 |
from rhodecode.lib.utils import repo2db_mapper, |
|
44 | from rhodecode.lib.utils import repo2db_mapper, set_rhodecode_config, \ | |
45 | set_rhodecode_config, repo_name_slug, check_git_version |
|
45 | check_git_version | |
46 | from rhodecode.model.db import RhodeCodeUi, Repository, RepoGroup, \ |
|
46 | from rhodecode.model.db import RhodeCodeUi, Repository, RepoGroup, \ | |
47 | RhodeCodeSetting, PullRequest, PullRequestReviewers |
|
47 | RhodeCodeSetting, PullRequest, PullRequestReviewers | |
48 | from rhodecode.model.forms import UserForm, ApplicationSettingsForm, \ |
|
48 | from rhodecode.model.forms import UserForm, ApplicationSettingsForm, \ | |
@@ -55,7 +55,6 b' from rhodecode.model.notification import' | |||||
55 | from rhodecode.model.meta import Session |
|
55 | from rhodecode.model.meta import Session | |
56 | from rhodecode.lib.utils2 import str2bool, safe_unicode |
|
56 | from rhodecode.lib.utils2 import str2bool, safe_unicode | |
57 | from rhodecode.lib.compat import json |
|
57 | from rhodecode.lib.compat import json | |
58 | from webob.exc import HTTPForbidden |
|
|||
59 | log = logging.getLogger(__name__) |
|
58 | log = logging.getLogger(__name__) | |
60 |
|
59 | |||
61 |
|
60 | |||
@@ -119,7 +118,7 b' class SettingsController(BaseController)' | |||||
119 | initial = ScmModel().repo_scan() |
|
118 | initial = ScmModel().repo_scan() | |
120 | log.debug('invalidating all repositories') |
|
119 | log.debug('invalidating all repositories') | |
121 | for repo_name in initial.keys(): |
|
120 | for repo_name in initial.keys(): | |
122 | invalidate_cache('get_repo_cached_%s' % repo_name) |
|
121 | ScmModel().mark_for_invalidation(repo_name) | |
123 |
|
122 | |||
124 | added, removed = repo2db_mapper(initial, rm_obsolete) |
|
123 | added, removed = repo2db_mapper(initial, rm_obsolete) | |
125 | _repr = lambda l: ', '.join(map(safe_unicode, l)) or '-' |
|
124 | _repr = lambda l: ', '.join(map(safe_unicode, l)) or '-' |
@@ -21,7 +21,7 b' from rhodecode.lib.utils2 import str2boo' | |||||
21 | safe_str, safe_int |
|
21 | safe_str, safe_int | |
22 | from rhodecode.lib.auth import AuthUser, get_container_username, authfunc,\ |
|
22 | from rhodecode.lib.auth import AuthUser, get_container_username, authfunc,\ | |
23 | HasPermissionAnyMiddleware, CookieStoreWrapper |
|
23 | HasPermissionAnyMiddleware, CookieStoreWrapper | |
24 |
from rhodecode.lib.utils import get_repo_slug |
|
24 | from rhodecode.lib.utils import get_repo_slug | |
25 | from rhodecode.model import meta |
|
25 | from rhodecode.model import meta | |
26 |
|
26 | |||
27 | from rhodecode.model.db import Repository, RhodeCodeUi, User, RhodeCodeSetting |
|
27 | from rhodecode.model.db import Repository, RhodeCodeUi, User, RhodeCodeSetting | |
@@ -149,7 +149,7 b' class BaseVCSController(object):' | |||||
149 |
|
149 | |||
150 | :param repo_name: full repo name, also a cache key |
|
150 | :param repo_name: full repo name, also a cache key | |
151 | """ |
|
151 | """ | |
152 | invalidate_cache('get_repo_cached_%s' % repo_name) |
|
152 | ScmModel().mark_for_invalidation(repo_name) | |
153 |
|
153 | |||
154 | def _check_permission(self, action, user, repo_name, ip_addr=None): |
|
154 | def _check_permission(self, action, user, repo_name, ip_addr=None): | |
155 | """ |
|
155 | """ |
@@ -356,19 +356,6 b' def set_rhodecode_config(config):' | |||||
356 | config[k] = v |
|
356 | config[k] = v | |
357 |
|
357 | |||
358 |
|
358 | |||
359 | def invalidate_cache(cache_key, *args): |
|
|||
360 | """ |
|
|||
361 | Puts cache invalidation task into db for |
|
|||
362 | further global cache invalidation |
|
|||
363 | """ |
|
|||
364 |
|
||||
365 | from rhodecode.model.scm import ScmModel |
|
|||
366 |
|
||||
367 | if cache_key.startswith('get_repo_cached_'): |
|
|||
368 | name = cache_key.split('get_repo_cached_')[-1] |
|
|||
369 | ScmModel().mark_for_invalidation(name) |
|
|||
370 |
|
||||
371 |
|
||||
372 | def map_groups(path): |
|
359 | def map_groups(path): | |
373 | """ |
|
360 | """ | |
374 | Given a full path to a repository, create all nested groups that this |
|
361 | Given a full path to a repository, create all nested groups that this |
@@ -1,9 +1,9 b'' | |||||
1 | from rhodecode.tests import * |
|
1 | from rhodecode.tests import * | |
2 | from rhodecode.tests.fixture import Fixture |
|
2 | from rhodecode.tests.fixture import Fixture | |
3 | from rhodecode.model.db import Repository |
|
3 | from rhodecode.model.db import Repository | |
4 | from rhodecode.lib.utils import invalidate_cache |
|
|||
5 | from rhodecode.model.repo import RepoModel |
|
4 | from rhodecode.model.repo import RepoModel | |
6 | from rhodecode.model.meta import Session |
|
5 | from rhodecode.model.meta import Session | |
|
6 | from rhodecode.model.scm import ScmModel | |||
7 |
|
7 | |||
8 | fixture = Fixture() |
|
8 | fixture = Fixture() | |
9 |
|
9 | |||
@@ -32,7 +32,7 b' class TestSummaryController(TestControll' | |||||
32 | #codes stats |
|
32 | #codes stats | |
33 | self._enable_stats() |
|
33 | self._enable_stats() | |
34 |
|
34 | |||
35 | invalidate_cache('get_repo_cached_%s' % HG_REPO) |
|
35 | ScmModel().mark_for_invalidation(HG_REPO) | |
36 | response = self.app.get(url(controller='summary', action='index', |
|
36 | response = self.app.get(url(controller='summary', action='index', | |
37 | repo_name=HG_REPO)) |
|
37 | repo_name=HG_REPO)) | |
38 | response.mustcontain( |
|
38 | response.mustcontain( |
General Comments 0
You need to be logged in to leave comments.
Login now