diff --git a/app/api/routes/node_storage.py b/app/api/routes/node_storage.py index c38737d..d9c452d 100644 --- a/app/api/routes/node_storage.py +++ b/app/api/routes/node_storage.py @@ -35,6 +35,15 @@ async def s_api_v1_storage_post(request): try: file_hash = b58encode(hashlib.sha256(file_content).digest()).decode() + stored_content = db_session.query(StoredContent).filter(StoredContent.hash == file_hash).first() + if stored_content: + stored_cid = stored_content.cid.serialize_v1() + return { + "content_sha256": file_hash, + "content_id_v1": stored_cid, + "content_url": f"dmy://storage?cid={stored_cid}", + } + new_content = StoredContent( type="local/content_bin", user_id=request.ctx.user.id,