fix upload existing
This commit is contained in:
parent
52663399cd
commit
9da4894a0b
|
|
@ -34,6 +34,20 @@ async def s_api_v1_5_storage_post(request):
|
|||
make_log("uploader_v1.5", f"Invalid X-Content-SHA256 header format: {e}", level="ERROR")
|
||||
return response.json({"error": "Invalid X-Content-SHA256 header format"}, status=400)
|
||||
|
||||
existing = request.ctx.db_session.query(StoredContent).filter_by(hash=provided_hash_b58).first()
|
||||
if existing:
|
||||
make_log("uploader_v1.5", f"File with hash {provided_hash_b58} already exists in DB", level="INFO")
|
||||
serialized_v2 = existing.cid.serialize_v2() # Get v2 content id
|
||||
serialized_v1 = existing.cid.serialize_v1() # Get v1 content id
|
||||
# Return early response since the file is already stored
|
||||
return response.json({
|
||||
"upload_id": request.headers.get("X-Upload-ID", str(uuid4())), # Use provided or generate a new upload_id
|
||||
"content_sha256": provided_hash_b58,
|
||||
"content_id": serialized_v2,
|
||||
"content_id_v1": serialized_v1,
|
||||
"content_url": f"dmy://storage?cid={serialized_v2}",
|
||||
})
|
||||
|
||||
# Get the provided file name from header and decode it from base64
|
||||
provided_filename_b64 = request.headers.get("X-File-Name")
|
||||
if not provided_filename_b64:
|
||||
|
|
|
|||
Loading…
Reference in New Issue