Changeset View
Changeset View
Standalone View
Standalone View
swh/web/ui/service.py
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | finally: | ||||
upload.cleanup(tmpdir) | upload.cleanup(tmpdir) | ||||
def lookup_hash(q): | def lookup_hash(q): | ||||
"""Checks if the storage contains a given content checksum | """Checks if the storage contains a given content checksum | ||||
Args: query string of the form <hash_algo:hash> | Args: query string of the form <hash_algo:hash> | ||||
Returns: Dict with key found to True or False, according to | Returns: Dict with key found containing the hash info if the | ||||
whether the checksum is present or not | hash is present, None if not. | ||||
""" | """ | ||||
algo, hash = query.parse_hash(q) | algo, hash = query.parse_hash(q) | ||||
found = backend.content_find(algo, hash) | found = backend.content_find(algo, hash) | ||||
return {'found': found, | return {'found': found, | ||||
'algo': algo} | 'algo': algo} | ||||
def search_hash(q): | |||||
"""Checks if the storage contains a given content checksum | |||||
Args: query string of the form <hash_algo:hash> | |||||
Returns: Dict with key found to True or False, according to | |||||
whether the checksum is present or not | |||||
""" | |||||
algo, hash = query.parse_hash(q) | |||||
found = backend.content_find(algo, hash) | |||||
return {'found': found is not None} | |||||
def lookup_hash_origin(q): | def lookup_hash_origin(q): | ||||
"""Return information about the checksum contained in the query q. | """Return information about the checksum contained in the query q. | ||||
Args: query string of the form <hash_algo:hash> | Args: query string of the form <hash_algo:hash> | ||||
Returns: | Returns: | ||||
origin as dictionary if found for the given content. | origin as dictionary if found for the given content. | ||||
▲ Show 20 Lines • Show All 515 Lines • Show Last 20 Lines |