Skip to content

Commit

Permalink
refactor: [#290] return 4009 intead of 400 trying to upload duplicate…
Browse files Browse the repository at this point in the history
… torrents

Torrents with the same original or canonical infohash.
  • Loading branch information
josecelano committed Mar 5, 2024
1 parent d500634 commit 414d468
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ pub fn http_status_code_for_service_error(error: &ServiceError) -> StatusCode {
ServiceError::InvalidTag => StatusCode::BAD_REQUEST,
ServiceError::Unauthorized => StatusCode::FORBIDDEN,
ServiceError::InfoHashAlreadyExists => StatusCode::BAD_REQUEST,
ServiceError::CanonicalInfoHashAlreadyExists => StatusCode::BAD_REQUEST,
ServiceError::OriginalInfoHashAlreadyExists => StatusCode::BAD_REQUEST,
ServiceError::CanonicalInfoHashAlreadyExists => StatusCode::CONFLICT,
ServiceError::OriginalInfoHashAlreadyExists => StatusCode::CONFLICT,
ServiceError::TorrentTitleAlreadyExists => StatusCode::BAD_REQUEST,
ServiceError::TrackerOffline => StatusCode::SERVICE_UNAVAILABLE,
ServiceError::CategoryNameEmpty => StatusCode::BAD_REQUEST,
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/web/api/v1/contexts/torrent/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ mod for_authenticated_users {
let form: UploadTorrentMultipartForm = first_torrent_clone.index_info.into();
let response = client.upload_torrent(form.into()).await;

assert_eq!(response.status, 400);
assert_eq!(response.status, 409);
}

#[tokio::test]
Expand Down Expand Up @@ -761,7 +761,7 @@ mod for_authenticated_users {
let form: UploadTorrentMultipartForm = torrent_with_the_same_canonical_info_hash.index_info.into();
let response = client.upload_torrent(form.into()).await;

assert_eq!(response.status, 400);
assert_eq!(response.status, 409);
}
}

Expand Down

0 comments on commit 414d468

Please sign in to comment.