Changeset - 12ca667b69b6
[Not reviewed]
beta
0 5 0
Mads Kiilerich - 13 years ago 2013-04-03 15:56:12
madski@unity3d.com
Grafted from: 0b9917e763f2
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.
5 files changed with 5 insertions and 12 deletions:
0 comments (0 inline, 0 general)
docs/api/api.rst
Show inline comments
 
@@ -171,7 +171,7 @@ INPUT::
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result : "Cache for repository `<reponame>` was invalidated: invalidated cache keys: <list_of_cache_keys>"
 
    result : "Caches of repository `<reponame>`"
 
    error :  null
 

	
 
lock
rhodecode/controllers/api/api.py
Show inline comments
 
@@ -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(
rhodecode/model/db.py
Show inline comments
 
@@ -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):
rhodecode/model/scm.py
Show inline comments
 
@@ -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):
 

	
rhodecode/tests/api/api_base.py
Show inline comments
 
@@ -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)
0 comments (0 inline, 0 general)