From b62ab5f4f433d8345405242c193743cb1a819c79 Mon Sep 17 00:00:00 2001 From: laanwj <126646+laanwj@users.noreply.github.com> Date: Thu, 21 Nov 2024 05:49:32 +0100 Subject: [PATCH] Don't fail when blob already uploaded When the blob was already uploaded by the same pubkey, don't treat this as a fatal error. Return the blob descriptor again, but without increasing reference count. Closes #12. --- src/handlers/mod.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index 1493fd5..a182ff7 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -515,11 +515,10 @@ pub async fn upload_blob_handler( Json(blob_descriptor).into_response() } Err(sqlx::Error::Database(db_err)) if db_err.is_unique_violation() => { - let error_message = ErrorResponse { - message: "Blob already uploaded by this public key".to_string(), - }; - let json = Json(error_message); - (StatusCode::CONFLICT, json).into_response() + // Blob already uploaded by this public key. + // Return the blob descriptor again, but without increasing the + // reference count. + Json(blob_descriptor).into_response() } Err(_) => { let error_message = ErrorResponse {