##// END OF EJS Templates
caches: fixed dbm keys calls to use bytes
super-admin -
r1082:58fdadac python3
parent child Browse files
Show More
@@ -37,7 +37,7 b' from dogpile.cache.api import Serializer'
37 from pyramid.settings import asbool
37 from pyramid.settings import asbool
38
38
39 from vcsserver.lib.memory_lru_dict import LRUDict, LRUDictDebug
39 from vcsserver.lib.memory_lru_dict import LRUDict, LRUDictDebug
40 from vcsserver.str_utils import safe_str
40 from vcsserver.str_utils import safe_str, safe_bytes
41
41
42
42
43 _default_max_size = 1024
43 _default_max_size = 1024
@@ -111,20 +111,20 b' class FileNamespaceBackend(PickleSeriali'
111 def __repr__(self):
111 def __repr__(self):
112 return '{} `{}`'.format(self.__class__, self.filename)
112 return '{} `{}`'.format(self.__class__, self.filename)
113
113
114 def list_keys(self, prefix=''):
114 def list_keys(self, prefix: bytes = b''):
115 prefix = '{}:{}'.format(self.key_prefix, prefix)
115 prefix = b'%b:%b' % (safe_bytes(self.key_prefix), safe_bytes(prefix))
116
116
117 def cond(v):
117 def cond(dbm_key: bytes):
118 if not prefix:
118 if not prefix:
119 return True
119 return True
120
120
121 if v.startswith(prefix):
121 if dbm_key.startswith(prefix):
122 return True
122 return True
123 return False
123 return False
124
124
125 with self._dbm_file(True) as dbm:
125 with self._dbm_file(True) as dbm:
126 try:
126 try:
127 return list(filter(cond, list(dbm.keys())))
127 return list(filter(cond, dbm.keys()))
128 except Exception:
128 except Exception:
129 log.error('Failed to fetch DBM keys from DB: %s', self.get_store())
129 log.error('Failed to fetch DBM keys from DB: %s', self.get_store())
130 raise
130 raise
General Comments 0
You need to be logged in to leave comments. Login now