Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/aleph/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ def get_defaults():
# Timeout for pinning operations (seconds)
"timeout": 60,
},
# Timeout for file stat requests (seconds)
"stat_timeout": 30,
},
"rabbitmq": {
# Hostname of the RabbitMQ service.
Expand Down
3 changes: 2 additions & 1 deletion src/aleph/handlers/content/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ async def fetch_related_content(
try:
# The timeout of the aioipfs client does not seem to work, time out manually
stats = await asyncio.wait_for(
ipfs_client.files.stat(f"/ipfs/{item_hash}"), 5
ipfs_client.files.stat(f"/ipfs/{item_hash}"),
config.ipfs.stat_timeout.value,
)
except aioipfs.InvalidCIDError as e:
raise UnknownHashError(
Expand Down
12 changes: 8 additions & 4 deletions src/aleph/web/controllers/ipfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,14 @@ async def ipfs_add_file(request: web.Request):

# IPFS add returns the cumulative size and not the real file size.
# We need the real file size here.
stats = await asyncio.wait_for(
ipfs_service.ipfs_client.files.stat(f"/ipfs/{cid}"), 5
)
size = stats["Size"]
try:
stats = await asyncio.wait_for(
ipfs_service.ipfs_client.files.stat(f"/ipfs/{cid}"),
config.ipfs.stat_timeout.value,
)
size = stats["Size"]
except TimeoutError:
raise web.HTTPNotFound(reason="File not found on IPFS")

with session_factory() as session:
upsert_file(
Expand Down
Loading