##// END OF EJS Templates
scm: added md5 methods to be calculated on vcsserver instead of RhodeCode side
super-admin -
r1074:ccf62cdf python3
parent child Browse files
Show More
@@ -161,11 +161,10 b' def get_or_create_region(region_name, re'
161 161 from vcsserver.lib.rc_cache.backends import FileNamespaceBackend
162 162 region_obj = region_meta.dogpile_cache_regions.get(region_name)
163 163 if not region_obj:
164 raise EnvironmentError(
165 'Region `{}` not in configured: {}.'.format(
166 region_name, list(region_meta.dogpile_cache_regions.keys())))
164 reg_keys = list(region_meta.dogpile_cache_regions.keys())
165 raise EnvironmentError(f'Region `{region_name}` not in configured: {reg_keys}.')
167 166
168 region_uid_name = '{}:{}'.format(region_name, region_namespace)
167 region_uid_name = f'{region_name}:{region_namespace}'
169 168 if isinstance(region_obj.actual_backend, FileNamespaceBackend):
170 169 region_exist = region_meta.dogpile_cache_regions.get(region_namespace)
171 170 if region_exist:
@@ -181,7 +180,7 b' def get_or_create_region(region_name, re'
181 180 function_key_generator=backend_key_generator(region_obj.actual_backend)
182 181 )
183 182 namespace_filename = os.path.join(
184 cache_dir, "{}.cache.dbm".format(region_namespace))
183 cache_dir, f"{region_namespace}.cache.dbm")
185 184 # special type that allows 1db per namespace
186 185 new_region.configure(
187 186 backend='dogpile.cache.rc.file_namespace',
@@ -273,6 +273,17 b' class GitRemote(RemoteBase):'
273 273 return _is_binary(repo_id, tree_id)
274 274
275 275 @reraise_safe_exceptions
276 def md5_hash(self, wire, tree_id):
277 cache_on, context_uid, repo_id = self._cache_on(wire)
278 region = self._region(wire)
279
280 @region.conditional_cache_on_arguments(condition=cache_on)
281 def _md5_hash(_repo_id, _tree_id):
282 return ''
283
284 return _md5_hash(repo_id, tree_id)
285
286 @reraise_safe_exceptions
276 287 def in_largefiles_store(self, wire, oid):
277 288 conf = self._wire_to_config(wire)
278 289 repo_init = self._factory.repo_libgit2(wire)
@@ -623,6 +623,20 b' class HgRemote(RemoteBase):'
623 623 return _is_binary(repo_id, revision, path)
624 624
625 625 @reraise_safe_exceptions
626 def md5_hash(self, wire, revision, path):
627 cache_on, context_uid, repo_id = self._cache_on(wire)
628 region = self._region(wire)
629
630 @region.conditional_cache_on_arguments(condition=cache_on)
631 def _md5_hash(_repo_id, _sha, _path):
632 repo = self._factory.repo(wire)
633 ctx = self._get_ctx(repo, revision)
634 fctx = ctx.filectx(safe_bytes(path))
635 return hashlib.md5(fctx.data()).hexdigest()
636
637 return _md5_hash(repo_id, revision, path)
638
639 @reraise_safe_exceptions
626 640 def in_largefiles_store(self, wire, sha):
627 641 repo = self._factory.repo(wire)
628 642 return largefiles.lfutil.instore(repo, sha)
@@ -472,8 +472,8 b' class SvnRemote(RemoteBase):'
472 472 @reraise_safe_exceptions
473 473 def is_binary(self, wire, rev, path):
474 474 cache_on, context_uid, repo_id = self._cache_on(wire)
475 region = self._region(wire)
475 476
476 region = self._region(wire)
477 477 @region.conditional_cache_on_arguments(condition=cache_on)
478 478 def _is_binary(_repo_id, _rev, _path):
479 479 raw_bytes = self.get_file_content(wire, path, rev)
@@ -482,6 +482,17 b' class SvnRemote(RemoteBase):'
482 482 return _is_binary(repo_id, rev, path)
483 483
484 484 @reraise_safe_exceptions
485 def md5_hash(self, wire, rev, path):
486 cache_on, context_uid, repo_id = self._cache_on(wire)
487 region = self._region(wire)
488
489 @region.conditional_cache_on_arguments(condition=cache_on)
490 def _md5_hash(_repo_id, _rev, _path):
491 return ''
492
493 return _md5_hash(repo_id, rev, path)
494
495 @reraise_safe_exceptions
485 496 def run_svn_command(self, wire, cmd, **opts):
486 497 path = wire.get('path', None)
487 498
General Comments 0
You need to be logged in to leave comments. Login now