Show More
@@ -0,0 +1,53 b'' | |||
|
1 | # RhodeCode VCSServer provides access to different vcs backends via network. | |
|
2 | # Copyright (C) 2014-2023 RhodeCode GmbH | |
|
3 | # | |
|
4 | # This program is free software; you can redistribute it and/or modify | |
|
5 | # it under the terms of the GNU General Public License as published by | |
|
6 | # the Free Software Foundation; either version 3 of the License, or | |
|
7 | # (at your option) any later version. | |
|
8 | # | |
|
9 | # This program is distributed in the hope that it will be useful, | |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
12 | # GNU General Public License for more details. | |
|
13 | # | |
|
14 | # You should have received a copy of the GNU General Public License | |
|
15 | # along with this program; if not, write to the Free Software Foundation, | |
|
16 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
|
17 | ||
|
18 | import hashlib | |
|
19 | from vcsserver.lib.str_utils import safe_bytes, safe_str | |
|
20 | ||
|
21 | ||
|
22 | def md5(s): | |
|
23 | return hashlib.md5(s).hexdigest() | |
|
24 | ||
|
25 | ||
|
26 | def md5_safe(s, return_type=''): | |
|
27 | ||
|
28 | val = md5(safe_bytes(s)) | |
|
29 | if return_type == 'str': | |
|
30 | val = safe_str(val) | |
|
31 | return val | |
|
32 | ||
|
33 | ||
|
34 | def sha1(s): | |
|
35 | return hashlib.sha1(s).hexdigest() | |
|
36 | ||
|
37 | ||
|
38 | def sha1_safe(s, return_type=''): | |
|
39 | val = sha1(safe_bytes(s)) | |
|
40 | if return_type == 'str': | |
|
41 | val = safe_str(val) | |
|
42 | return val | |
|
43 | ||
|
44 | ||
|
45 | def sha256(s): | |
|
46 | return hashlib.sha256(s).hexdigest() | |
|
47 | ||
|
48 | ||
|
49 | def sha256_safe(s, return_type=''): | |
|
50 | val = sha256(safe_bytes(s)) | |
|
51 | if return_type == 'str': | |
|
52 | val = safe_str(val) | |
|
53 | return val |
@@ -37,9 +37,9 b' from dogpile.cache.backends import redis' | |||
|
37 | 37 | from dogpile.cache.backends.file import FileLock |
|
38 | 38 | from dogpile.cache.util import memoized_property |
|
39 | 39 | |
|
40 |
from |
|
|
41 |
from |
|
|
42 |
from |
|
|
40 | from ...lib.memory_lru_dict import LRUDict, LRUDictDebug | |
|
41 | from ...lib.str_utils import safe_bytes, safe_str | |
|
42 | from ...lib.type_utils import str2bool | |
|
43 | 43 | |
|
44 | 44 | _default_max_size = 1024 |
|
45 | 45 | |
@@ -166,6 +166,13 b' class FileNamespaceBackend(PickleSeriali' | |||
|
166 | 166 | def get_store(self): |
|
167 | 167 | return self.filename |
|
168 | 168 | |
|
169 | def cleanup_store(self): | |
|
170 | for ext in ("db", "dat", "pag", "dir"): | |
|
171 | final_filename = self.filename + os.extsep + ext | |
|
172 | if os.path.exists(final_filename): | |
|
173 | os.remove(final_filename) | |
|
174 | log.warning('Removed dbm file %s', final_filename) | |
|
175 | ||
|
169 | 176 | |
|
170 | 177 | class BaseRedisBackend(redis_backend.RedisBackend): |
|
171 | 178 | key_prefix = '' |
@@ -257,7 +264,7 b' class RedisMsgPackBackend(MsgPackSeriali' | |||
|
257 | 264 | |
|
258 | 265 | |
|
259 | 266 | def get_mutex_lock(client, lock_key, lock_timeout, auto_renewal=False): |
|
260 |
from |
|
|
267 | from ...lib._vendor import redis_lock | |
|
261 | 268 | |
|
262 | 269 | class _RedisLockWrapper: |
|
263 | 270 | """LockWrapper for redis_lock""" |
@@ -25,9 +25,9 b' import decorator' | |||
|
25 | 25 | from dogpile.cache import CacheRegion |
|
26 | 26 | |
|
27 | 27 | |
|
28 |
from |
|
|
29 |
from |
|
|
30 |
from |
|
|
28 | from ...lib.hash_utils import sha1 | |
|
29 | from ...lib.str_utils import safe_bytes | |
|
30 | from ...lib.type_utils import str2bool # noqa :required by imports from .utils | |
|
31 | 31 | |
|
32 | 32 | from . import region_meta |
|
33 | 33 |
General Comments 0
You need to be logged in to leave comments.
Login now