Skip to content

Commit ef2bfdd

Browse files
committed
Internal: lazy check if IPFS is enabled in storage code
Problem: the config is checked eagerly to determine whether the IPFS daemon is enabled on the node, even if the file hash is not an IPFS CID. Solution: check lazily instead.
1 parent 574c9e6 commit ef2bfdd

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/aleph/storage.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,6 @@ async def get_hash_content(
176176
store_value: bool = True,
177177
) -> RawContent:
178178
# TODO: determine which storage engine to use
179-
config = get_config()
180-
ipfs_enabled = config.ipfs.enabled.value
181179

182180
source = None
183181

@@ -193,11 +191,14 @@ async def get_hash_content(
193191
source = ContentSource.P2P
194192

195193
if content is None:
196-
if ipfs_enabled and engine == ItemType.ipfs and use_ipfs:
197-
content = await self.ipfs_service.get_ipfs_content(
198-
content_hash, timeout=timeout, tries=tries
199-
)
200-
source = ContentSource.IPFS
194+
if use_ipfs and engine == ItemType.ipfs:
195+
config = get_config()
196+
ipfs_enabled = config.ipfs.enabled.value
197+
if ipfs_enabled:
198+
content = await self.ipfs_service.get_ipfs_content(
199+
content_hash, timeout=timeout, tries=tries
200+
)
201+
source = ContentSource.IPFS
201202

202203
if content is None:
203204
raise ContentCurrentlyUnavailable(

0 commit comments

Comments
 (0)