##// END OF EJS Templates
api: don't report invalidated cache_keys after invalidating a repo...
Mads Kiilerich -
r3759:12ca667b beta
parent child Browse files
Show More
@@ -171,7 +171,7 b' INPUT::'
171 OUTPUT::
171 OUTPUT::
172
172
173 id : <id_given_in_input>
173 id : <id_given_in_input>
174 result : "Cache for repository `<reponame>` was invalidated: invalidated cache keys: <list_of_cache_keys>"
174 result : "Caches of repository `<reponame>`"
175 error : null
175 error : null
176
176
177 lock
177 lock
@@ -220,9 +220,8 b' class ApiController(JSONRPCController):'
220 raise JSONRPCError('repository `%s` does not exist' % (repoid))
220 raise JSONRPCError('repository `%s` does not exist' % (repoid))
221
221
222 try:
222 try:
223 invalidated_keys = ScmModel().mark_for_invalidation(repo.repo_name)
223 ScmModel().mark_for_invalidation(repo.repo_name)
224 return ('Cache for repository `%s` was invalidated: '
224 return ('Caches of repository `%s` was invalidated' % repoid)
225 'invalidated cache keys: %s' % (repoid, invalidated_keys))
226 except Exception:
225 except Exception:
227 log.error(traceback.format_exc())
226 log.error(traceback.format_exc())
228 raise JSONRPCError(
227 raise JSONRPCError(
@@ -1857,7 +1857,6 b' class CacheInvalidation(Base, BaseModel)'
1857 """
1857 """
1858 Mark all caches of a repo as invalid in the database.
1858 Mark all caches of a repo as invalid in the database.
1859 """
1859 """
1860 invalidated_keys = []
1861 inv_objs = Session().query(cls).filter(cls.cache_args == repo_name).all()
1860 inv_objs = Session().query(cls).filter(cls.cache_args == repo_name).all()
1862
1861
1863 try:
1862 try:
@@ -1865,13 +1864,11 b' class CacheInvalidation(Base, BaseModel)'
1865 log.debug('marking %s key for invalidation based on repo_name=%s'
1864 log.debug('marking %s key for invalidation based on repo_name=%s'
1866 % (inv_obj, safe_str(repo_name)))
1865 % (inv_obj, safe_str(repo_name)))
1867 inv_obj.cache_active = False
1866 inv_obj.cache_active = False
1868 invalidated_keys.append(inv_obj.cache_key)
1869 Session().add(inv_obj)
1867 Session().add(inv_obj)
1870 Session().commit()
1868 Session().commit()
1871 except Exception:
1869 except Exception:
1872 log.error(traceback.format_exc())
1870 log.error(traceback.format_exc())
1873 Session().rollback()
1871 Session().rollback()
1874 return invalidated_keys
1875
1872
1876 @classmethod
1873 @classmethod
1877 def set_valid(cls, cache_key):
1874 def set_valid(cls, cache_key):
@@ -322,11 +322,10 b' class ScmModel(BaseModel):'
322
322
323 :param repo_name: the repo for which caches should be marked invalid
323 :param repo_name: the repo for which caches should be marked invalid
324 """
324 """
325 invalidated_keys = CacheInvalidation.set_invalidate(repo_name)
325 CacheInvalidation.set_invalidate(repo_name)
326 repo = Repository.get_by_repo_name(repo_name)
326 repo = Repository.get_by_repo_name(repo_name)
327 if repo:
327 if repo:
328 repo.update_changeset_cache()
328 repo.update_changeset_cache()
329 return invalidated_keys
330
329
331 def toggle_following_repo(self, follow_repo_id, user_id):
330 def toggle_following_repo(self, follow_repo_id, user_id):
332
331
@@ -268,9 +268,7 b' class BaseTestApi(object):'
268 repoid=self.REPO)
268 repoid=self.REPO)
269 response = api_call(self, params)
269 response = api_call(self, params)
270
270
271 expected = ("Cache for repository `%s` was invalidated: "
271 expected = ("Caches of repository `%s` was invalidated" % (self.REPO))
272 "invalidated cache keys: %s" % (self.REPO,
273 [unicode(self.REPO)]))
274 self._compare_ok(id_, expected, given=response.body)
272 self._compare_ok(id_, expected, given=response.body)
275
273
276 @mock.patch.object(ScmModel, 'mark_for_invalidation', crash)
274 @mock.patch.object(ScmModel, 'mark_for_invalidation', crash)
General Comments 0
You need to be logged in to leave comments. Login now