Changeset View
Changeset View
Standalone View
Standalone View
swh/web/common/archive.py
Show First 20 Lines • Show All 860 Lines • ▼ Show 20 Lines | def lookup_content_raw(q: str) -> Dict[str, Any]: | ||||
Raises: | Raises: | ||||
NotFoundExc if the requested content is not found or | NotFoundExc if the requested content is not found or | ||||
if the content bytes are not available in the storage | if the content bytes are not available in the storage | ||||
""" | """ | ||||
c = lookup_content(q) | c = lookup_content(q) | ||||
content_sha1_bytes = hashutil.hash_to_bytes(c["checksums"]["sha1"]) | content_sha1_bytes = hashutil.hash_to_bytes(c["checksums"]["sha1"]) | ||||
content_data = storage.content_get_data(content_sha1_bytes) | content_data = storage.content_get_data(content_sha1_bytes) | ||||
if not content_data: | if content_data is None: | ||||
algo, hash_ = query.parse_hash(q) | algo, hash_ = query.parse_hash(q) | ||||
raise NotFoundExc( | raise NotFoundExc( | ||||
f"Bytes of content with {algo} checksum equals " | f"Bytes of content with {algo} checksum equals " | ||||
f"to {hashutil.hash_to_hex(hash_)} are not available!" | f"to {hashutil.hash_to_hex(hash_)} are not available!" | ||||
) | ) | ||||
return converters.from_content({"sha1": content_sha1_bytes, "data": content_data}) | return converters.from_content({"sha1": content_sha1_bytes, "data": content_data}) | ||||
▲ Show 20 Lines • Show All 481 Lines • Show Last 20 Lines |