Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/in_memory.py
Show First 20 Lines • Show All 283 Lines • ▼ Show 20 Lines | def content_find(self, content): | ||||
if not set(content).intersection(DEFAULT_ALGORITHMS): | if not set(content).intersection(DEFAULT_ALGORITHMS): | ||||
raise ValueError('content keys must contain at least one of: ' | raise ValueError('content keys must contain at least one of: ' | ||||
'%s' % ', '.join(sorted(DEFAULT_ALGORITHMS))) | '%s' % ', '.join(sorted(DEFAULT_ALGORITHMS))) | ||||
found = [] | found = [] | ||||
for algo in DEFAULT_ALGORITHMS: | for algo in DEFAULT_ALGORITHMS: | ||||
hash = content.get(algo) | hash = content.get(algo) | ||||
if hash and hash in self._content_indexes[algo]: | if hash and hash in self._content_indexes[algo]: | ||||
found.append(self._content_indexes[algo][hash]) | found.append(self._content_indexes[algo][hash]) | ||||
if not found: | if not found: | ||||
return | return [] | ||||
keys = list(set.intersection(*found)) | keys = list(set.intersection(*found)) | ||||
return copy.deepcopy([self._contents[key] for key in keys]) | return copy.deepcopy([self._contents[key] for key in keys]) | ||||
def content_missing(self, contents, key_hash='sha1'): | def content_missing(self, contents, key_hash='sha1'): | ||||
"""List content missing from storage | """List content missing from storage | ||||
Args: | Args: | ||||
contents ([dict]): iterable of dictionaries whose keys are | contents ([dict]): iterable of dictionaries whose keys are | ||||
▲ Show 20 Lines • Show All 1,236 Lines • Show Last 20 Lines |