Skip to content

Commit a7f43dc

Browse files
committed
refactor: rename fields in upload torrent response
to match latest changes in the database. From: ```json { "data": { "torrent_id": 12, "info_hash": "c01f910ff0cc2a1b8c7a1f6ab948377604d8c464", "original_info_hash": "dc0c6be689b28696319263ef27f9df4da8ded0a2" } } ``` To: ``` { "data": { "torrent_id": 12, "canonical_info_hash": "c01f910ff0cc2a1b8c7a1f6ab948377604d8c464", "info_hash": "dc0c6be689b28696319263ef27f9df4da8ded0a2" } } ```
1 parent f5cfc33 commit a7f43dc

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

src/services/torrent.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ pub struct AddTorrentRequest {
4545

4646
pub struct AddTorrentResponse {
4747
pub torrent_id: TorrentId,
48+
pub canonical_info_hash: String,
4849
pub info_hash: String,
49-
pub original_info_hash: String,
5050
}
5151

5252
/// User request to generate a torrent listing.
@@ -172,8 +172,8 @@ impl Index {
172172

173173
Ok(AddTorrentResponse {
174174
torrent_id,
175-
info_hash: torrent.canonical_info_hash_hex(),
176-
original_info_hash: original_info_hash.to_string(),
175+
canonical_info_hash: torrent.canonical_info_hash_hex(),
176+
info_hash: original_info_hash.to_string(),
177177
})
178178
}
179179

src/web/api/server/v1/contexts/torrent/responses.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ use crate::web::api::server::v1::responses::OkResponseData;
1111
#[derive(Serialize, Deserialize, Debug)]
1212
pub struct NewTorrentResponseData {
1313
pub torrent_id: TorrentId,
14+
pub canonical_info_hash: String,
1415
pub info_hash: String,
15-
pub original_info_hash: String,
1616
}
1717

1818
/// Response after successfully uploading a new torrent.
1919
pub fn new_torrent_response(add_torrent_response: &AddTorrentResponse) -> Json<OkResponseData<NewTorrentResponseData>> {
2020
Json(OkResponseData {
2121
data: NewTorrentResponseData {
2222
torrent_id: add_torrent_response.torrent_id,
23+
canonical_info_hash: add_torrent_response.canonical_info_hash.clone(),
2324
info_hash: add_torrent_response.info_hash.clone(),
24-
original_info_hash: add_torrent_response.original_info_hash.clone(),
2525
},
2626
})
2727
}

tests/common/contexts/torrent/responses.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ pub struct UploadedTorrentResponse {
103103
#[derive(Deserialize, PartialEq, Debug)]
104104
pub struct UploadedTorrent {
105105
pub torrent_id: Id,
106+
pub canonical_info_hash: String,
106107
pub info_hash: String,
107108
}
108109

tests/e2e/web/api/v1/contexts/torrent/contract.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ mod for_authenticated_users {
504504
let uploaded_torrent_response: UploadedTorrentResponse = serde_json::from_str(&response.body).unwrap();
505505

506506
assert_eq!(
507-
uploaded_torrent_response.data.info_hash.to_lowercase(),
507+
uploaded_torrent_response.data.canonical_info_hash.to_lowercase(),
508508
info_hash.to_lowercase()
509509
);
510510
assert!(response.is_json_and_ok());

tests/e2e/web/api/v1/contexts/torrent/steps.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub async fn upload_test_torrent(client: &Client, test_torrent: &TestTorrent) ->
5050
}
5151

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

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

0 commit comments

Comments
 (0)