Skip to content

Commit f4b93c3

Browse files
committed
Fix: Solve issue with not rejecting messages that it's content doesn't exist on IPFS.
1 parent 440c96a commit f4b93c3

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/aleph/services/ipfs/service.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from aleph.services.ipfs.common import make_ipfs_client
1212
from aleph.services.utils import get_IP
13-
from aleph.types.message_status import FileUnavailable
13+
from aleph.types.message_status import FileContentUnavailable, FileUnavailable
1414
from aleph.utils import run_in_executor
1515

1616
LOGGER = logging.getLogger(__name__)
@@ -113,8 +113,9 @@ async def get_ipfs_size(
113113
await asyncio.sleep(0.5)
114114
continue
115115
except asyncio.TimeoutError:
116-
result = None
117-
await asyncio.sleep(0.5)
116+
raise FileContentUnavailable(
117+
"Could not retrieve IPFS content at this time"
118+
)
118119
except (
119120
concurrent.futures.CancelledError,
120121
aiohttp.client_exceptions.ClientConnectorError,

src/aleph/types/message_status.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,16 @@ def __init__(self, file_hash: str):
169169
super().__init__(f"File not found: {file_hash}")
170170

171171

172+
class FileContentNotFoundException(RetryMessageException):
173+
"""
174+
A file required to process the message could not be found, locally and/or
175+
on the network.
176+
"""
177+
178+
def __init__(self, file_hash: str):
179+
super().__init__(f"File content not found: {file_hash}")
180+
181+
172182
class MessageContentUnavailable(FileNotFoundException):
173183
"""
174184
The message content is not available at the moment (storage/IPFS item types).
@@ -185,6 +195,14 @@ class FileUnavailable(FileNotFoundException):
185195
error_code = ErrorCode.FILE_UNAVAILABLE
186196

187197

198+
class FileContentUnavailable(FileContentNotFoundException):
199+
"""
200+
A file pointed to by the message is not available at the moment.
201+
"""
202+
203+
error_code = ErrorCode.FILE_UNAVAILABLE
204+
205+
188206
class NoAmendTarget(InvalidMessageException):
189207
"""
190208
A POST with type = amend does not specify a value in the ref field.

0 commit comments

Comments
 (0)