Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/services/torrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ pub struct AddTorrentRequest {

pub struct AddTorrentResponse {
pub torrent_id: TorrentId,
pub canonical_info_hash: String,
pub info_hash: String,
pub original_info_hash: String,
}

/// User request to generate a torrent listing.
Expand Down Expand Up @@ -172,8 +172,8 @@ impl Index {

Ok(AddTorrentResponse {
torrent_id,
info_hash: torrent.canonical_info_hash_hex(),
original_info_hash: original_info_hash.to_string(),
canonical_info_hash: torrent.canonical_info_hash_hex(),
info_hash: original_info_hash.to_string(),
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/web/api/server/v1/contexts/torrent/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ use crate::web::api::server::v1::responses::OkResponseData;
#[derive(Serialize, Deserialize, Debug)]
pub struct NewTorrentResponseData {
pub torrent_id: TorrentId,
pub canonical_info_hash: String,
pub info_hash: String,
pub original_info_hash: String,
}

/// Response after successfully uploading a new torrent.
pub fn new_torrent_response(add_torrent_response: &AddTorrentResponse) -> Json<OkResponseData<NewTorrentResponseData>> {
Json(OkResponseData {
data: NewTorrentResponseData {
torrent_id: add_torrent_response.torrent_id,
canonical_info_hash: add_torrent_response.canonical_info_hash.clone(),
info_hash: add_torrent_response.info_hash.clone(),
original_info_hash: add_torrent_response.original_info_hash.clone(),
},
})
}
Expand Down
1 change: 1 addition & 0 deletions tests/common/contexts/torrent/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ pub struct UploadedTorrentResponse {
#[derive(Deserialize, PartialEq, Debug)]
pub struct UploadedTorrent {
pub torrent_id: Id,
pub canonical_info_hash: String,
pub info_hash: String,
}

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/web/api/v1/contexts/torrent/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ mod for_authenticated_users {
let uploaded_torrent_response: UploadedTorrentResponse = serde_json::from_str(&response.body).unwrap();

assert_eq!(
uploaded_torrent_response.data.info_hash.to_lowercase(),
uploaded_torrent_response.data.canonical_info_hash.to_lowercase(),
info_hash.to_lowercase()
);
assert!(response.is_json_and_ok());
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/web/api/v1/contexts/torrent/steps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub async fn upload_test_torrent(client: &Client, test_torrent: &TestTorrent) ->
}

let uploaded_torrent_response: UploadedTorrentResponse = serde_json::from_str(&response.body).unwrap();
let canonical_info_hash_hex = uploaded_torrent_response.data.info_hash.to_lowercase();
let canonical_info_hash_hex = uploaded_torrent_response.data.canonical_info_hash.to_lowercase();

let canonical_info_hash = InfoHash::from_str(&canonical_info_hash_hex)
.unwrap_or_else(|_| panic!("Invalid info-hash in database: {canonical_info_hash_hex}"));
Expand Down