Skip to content

Commit

Permalink
Merge torrust#570: Remove always-empty peer list in torrent list item
Browse files Browse the repository at this point in the history
d03e930 feat!: [torrust#536] remove always-empty peer list in torrent list item (Jose Celano)

Pull request description:

  The endpoint to get the list of torrents returns a list of items like this:

  ```json
  [
    {
      "info_hash": "0031ad8520ddfebd856d70776063e477eaf07ada",
      "seeders": 0,
      "completed": 0,
      "leechers": 1,
      "peers": null
      }
  ]
  ```

  The `peers` list is always `null` even if there are peers. That's very confusing especially if you enable the config option `remove_peerless_torrents`.

  This PR removes that unused attribute.

ACKs for top commit:
  josecelano:
    ACK d03e930

Tree-SHA512: 822c984c92dad44355428062e878b2316cb72b42fd418a9f7d6cec5667b828a70ad361af824a8b682979d90d6eda99715358fbc27aac012a89cb72ae8bcf5343
  • Loading branch information
josecelano committed Jan 2, 2024
2 parents 9826400 + d03e930 commit 69fe572
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 8 deletions.
5 changes: 0 additions & 5 deletions src/servers/apis/v1/context/torrent/resources/torrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ pub struct ListItem {
/// The torrent's leechers counter. Active peers that are downloading the
/// torrent.
pub leechers: u64,
/// The torrent's peers. It's always `None` in the struct and `null` in the
/// JSON response.
pub peers: Option<Vec<super::peer::Peer>>, // todo: this is always None. Remove field from endpoint?
}

impl ListItem {
Expand Down Expand Up @@ -90,7 +87,6 @@ impl From<BasicInfo> for ListItem {
seeders: basic_info.seeders,
completed: basic_info.completed,
leechers: basic_info.leechers,
peers: None,
}
}
}
Expand Down Expand Up @@ -156,7 +152,6 @@ mod tests {
seeders: 1,
completed: 2,
leechers: 3,
peers: None,
}
);
}
Expand Down
3 changes: 0 additions & 3 deletions tests/servers/api/v1/contract/context/torrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ async fn should_allow_getting_torrents() {
seeders: 1,
completed: 0,
leechers: 0,
peers: None, // Torrent list does not include the peer list for each torrent
}],
)
.await;
Expand Down Expand Up @@ -65,7 +64,6 @@ async fn should_allow_limiting_the_torrents_in_the_result() {
seeders: 1,
completed: 0,
leechers: 0,
peers: None, // Torrent list does not include the peer list for each torrent
}],
)
.await;
Expand Down Expand Up @@ -95,7 +93,6 @@ async fn should_allow_the_torrents_result_pagination() {
seeders: 1,
completed: 0,
leechers: 0,
peers: None, // Torrent list does not include the peer list for each torrent
}],
)
.await;
Expand Down

0 comments on commit 69fe572

Please sign in to comment.