packages/reflex-cache: don't 502 if pinning to ipfs cluster fails

This commit is contained in:
Max Headroom 2023-11-10 00:51:12 +01:00
parent 8edd39d462
commit 089e570054

View file

@ -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)
rClusterPin = requests_unixsocket.post( try:
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 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
if rClusterPin.status_code != 200: )
print(f"Warning: failed to pin {hash} on IPFS cluster") if rClusterPin.status_code != 200:
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: