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 = ' |
|
115 | prefix = b'%b:%b' % (safe_bytes(self.key_prefix), safe_bytes(prefix)) | |
116 |
|
116 | |||
117 |
def cond( |
|
117 | def cond(dbm_key: bytes): | |
118 | if not prefix: |
|
118 | if not prefix: | |
119 | return True |
|
119 | return True | |
120 |
|
120 | |||
121 |
if |
|
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, |
|
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