##// END OF EJS Templates
caches: fixed filename backend crash by using sanitazed cache_repo_id instead of one with '/' in the name.
super-admin -
r996:3f24ad23 default
parent child Browse files
Show More
@@ -1,45 +1,46 b''
1 1 # RhodeCode VCSServer provides access to different vcs backends via network.
2 2 # Copyright (C) 2014-2020 RhodeCode GmbH
3 3 #
4 4 # This program is free software; you can redistribute it and/or modify
5 5 # it under the terms of the GNU General Public License as published by
6 6 # the Free Software Foundation; either version 3 of the License, or
7 7 # (at your option) any later version.
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 General Public License
15 15 # along with this program; if not, write to the Free Software Foundation,
16 16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 17
18 18 from vcsserver.lib import rc_cache
19 19
20 20 class RemoteBase(object):
21 21 EMPTY_COMMIT = '0' * 40
22 22
23 23 def _region(self, wire):
24 repo_id = wire.get('repo_id', '')
25 cache_namespace_uid = 'cache_repo.{}'.format(repo_id)
24 cache_repo_id = wire.get('cache_repo_id', '')
25 cache_namespace_uid = 'cache_repo.{}'.format(cache_repo_id)
26 26 return rc_cache.get_or_create_region('repo_object', cache_namespace_uid)
27 27
28 28 def _cache_on(self, wire):
29 29 context = wire.get('context', '')
30 30 context_uid = '{}'.format(context)
31 31 repo_id = wire.get('repo_id', '')
32 32 cache = wire.get('cache', True)
33 33 cache_on = context and cache
34 34 return cache_on, context_uid, repo_id
35 35
36 36 def vcsserver_invalidate_cache(self, wire, delete):
37 37 from vcsserver.lib import rc_cache
38 38 repo_id = wire.get('repo_id', '')
39 cache_repo_id = wire.get('cache_repo_id', '')
40 cache_namespace_uid = 'cache_repo.{}'.format(cache_repo_id)
39 41
40 42 if delete:
41 cache_namespace_uid = 'cache_repo.{}'.format(repo_id)
42 43 rc_cache.clear_cache_namespace(
43 44 'repo_object', cache_namespace_uid, invalidate=True)
44 45
45 46 return {'invalidated': {'repo_id': repo_id, 'delete': delete}}
General Comments 0
You need to be logged in to leave comments. Login now