# HG changeset patch # User Mads Kiilerich # Date 2013-04-03 13:56:12 # Node ID 12ca667b69b6f183293cc863bdcb48ae6d4b8222 # Parent d5c684052ea40fc75292aa2fbb3e3e0047d3836d api: don't report invalidated cache_keys after invalidating a repo The keys are an implementation detail and is never relevant outside RhodeCode internals and should not be leaked. diff --git a/docs/api/api.rst b/docs/api/api.rst --- a/docs/api/api.rst +++ b/docs/api/api.rst @@ -171,7 +171,7 @@ INPUT:: OUTPUT:: id : - result : "Cache for repository `` was invalidated: invalidated cache keys: " + result : "Caches of repository ``" error : null lock diff --git a/rhodecode/controllers/api/api.py b/rhodecode/controllers/api/api.py --- a/rhodecode/controllers/api/api.py +++ b/rhodecode/controllers/api/api.py @@ -220,9 +220,8 @@ class ApiController(JSONRPCController): raise JSONRPCError('repository `%s` does not exist' % (repoid)) try: - invalidated_keys = ScmModel().mark_for_invalidation(repo.repo_name) - return ('Cache for repository `%s` was invalidated: ' - 'invalidated cache keys: %s' % (repoid, invalidated_keys)) + ScmModel().mark_for_invalidation(repo.repo_name) + return ('Caches of repository `%s` was invalidated' % repoid) except Exception: log.error(traceback.format_exc()) raise JSONRPCError( diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -1857,7 +1857,6 @@ class CacheInvalidation(Base, BaseModel) """ Mark all caches of a repo as invalid in the database. """ - invalidated_keys = [] inv_objs = Session().query(cls).filter(cls.cache_args == repo_name).all() try: @@ -1865,13 +1864,11 @@ class CacheInvalidation(Base, BaseModel) log.debug('marking %s key for invalidation based on repo_name=%s' % (inv_obj, safe_str(repo_name))) inv_obj.cache_active = False - invalidated_keys.append(inv_obj.cache_key) Session().add(inv_obj) Session().commit() except Exception: log.error(traceback.format_exc()) Session().rollback() - return invalidated_keys @classmethod def set_valid(cls, cache_key): diff --git a/rhodecode/model/scm.py b/rhodecode/model/scm.py --- a/rhodecode/model/scm.py +++ b/rhodecode/model/scm.py @@ -322,11 +322,10 @@ class ScmModel(BaseModel): :param repo_name: the repo for which caches should be marked invalid """ - invalidated_keys = CacheInvalidation.set_invalidate(repo_name) + CacheInvalidation.set_invalidate(repo_name) repo = Repository.get_by_repo_name(repo_name) if repo: repo.update_changeset_cache() - return invalidated_keys def toggle_following_repo(self, follow_repo_id, user_id): diff --git a/rhodecode/tests/api/api_base.py b/rhodecode/tests/api/api_base.py --- a/rhodecode/tests/api/api_base.py +++ b/rhodecode/tests/api/api_base.py @@ -268,9 +268,7 @@ class BaseTestApi(object): repoid=self.REPO) response = api_call(self, params) - expected = ("Cache for repository `%s` was invalidated: " - "invalidated cache keys: %s" % (self.REPO, - [unicode(self.REPO)])) + expected = ("Caches of repository `%s` was invalidated" % (self.REPO)) self._compare_ok(id_, expected, given=response.body) @mock.patch.object(ScmModel, 'mark_for_invalidation', crash)