Skip to content

Commit

Permalink
Merge pull request #26 from laanwj/2024-11-the-same-blob
Browse files Browse the repository at this point in the history
Don't fail when blob already uploaded
  • Loading branch information
0xtrr authored Nov 21, 2024
2 parents 70e7e3c + b62ab5f commit b1f7e77
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b1f7e77

Please sign in to comment.