diff --git a/swh/web/common/service.py b/swh/web/common/service.py --- a/swh/web/common/service.py +++ b/swh/web/common/service.py @@ -88,7 +88,9 @@ """ algo, hash = query.parse_hash(q) - found = storage.content_find({algo: hash}) + found = None + if storage.content_find({algo: hash}): + found = storage.content_find({algo: hash})[0] return {'found': converters.from_content(found), 'algo': algo} @@ -104,7 +106,7 @@ """ algo, hash = query.parse_hash(q) found = storage.content_find({algo: hash}) - return {'found': found is not None} + return {'found': bool(found)} def _lookup_content_sha1(q): @@ -122,7 +124,7 @@ hashes = storage.content_find({algo: hash}) if not hashes: return None - return hashes['sha1'] + return hashes[0]['sha1'] return hash @@ -717,7 +719,9 @@ 'content': list(map(converters.from_directory_entry, directory_entries))} elif entity['type'] == 'file': # content - content = storage.content_find({'sha1_git': entity['target']}) + content = None + if storage.content_find({'sha1_git': entity['target']}): + content = storage.content_find({'sha1_git': entity['target']})[0] if with_data: c = _first_element(storage.content_get([content['sha1']])) content['data'] = c['data'] @@ -751,7 +755,7 @@ if not c: raise NotFoundExc('Content with %s checksum equals to %s not found!' % (algo, hashutil.hash_to_hex(hash))) - return converters.from_content(c) + return converters.from_content(c[0]) def lookup_content_raw(q):