packages/reflex-cache: don't 502 if pinning to ipfs cluster fails
This commit is contained in:
parent
8edd39d462
commit
089e570054
1 changed files with 8 additions and 5 deletions
|
@ -32,11 +32,14 @@ class IPFSController:
|
||||||
print(f"Mapped: {nar} -> /ipfs/{hash}")
|
print(f"Mapped: {nar} -> /ipfs/{hash}")
|
||||||
self.__db.set_path(nar, hash)
|
self.__db.set_path(nar, hash)
|
||||||
expireAt = datetime.now(timezone.utc) + timedelta(hours=24)
|
expireAt = datetime.now(timezone.utc) + timedelta(hours=24)
|
||||||
|
try:
|
||||||
rClusterPin = requests_unixsocket.post(
|
rClusterPin = requests_unixsocket.post(
|
||||||
f"{self.__clusterAddr}/pins/ipfs/{hash}?expire-at={quote_plus(expireAt.isoformat())}&mode=recursive&name=reflex-{quote_plus(nar)}&replication-max=2&replication-min=1", files=upload
|
f"{self.__clusterAddr}/pins/ipfs/{hash}?expire-at={quote_plus(expireAt.isoformat())}&mode=recursive&name=reflex-{quote_plus(nar)}&replication-max=2&replication-min=1", files=upload
|
||||||
)
|
)
|
||||||
if rClusterPin.status_code != 200:
|
if rClusterPin.status_code != 200:
|
||||||
print(f"Warning: failed to pin {hash} on IPFS cluster")
|
print(f"Warning: failed to pin {hash} on IPFS cluster: {rClusterPin.status_code}")
|
||||||
|
except requests.ConnectionError as e:
|
||||||
|
print(f"Warning: failed to pin {hash} on IPFS cluster: {e}")
|
||||||
callback()
|
callback()
|
||||||
return (nar, 200, hash)
|
return (nar, 200, hash)
|
||||||
except requests.ConnectionError as e:
|
except requests.ConnectionError as e:
|
||||||
|
|
Loading…
Reference in a new issue