Skip to content

Commit

Permalink
fix: [torrust#56] announce list has precedence over announce
Browse files Browse the repository at this point in the history
From BEP-12:

"In addition to the standard "announce" key, in the main area of the metadata file and not part of the "info" section, will be a new key, "announce-list". This key will refer to a list of lists of URLs, and will contain a list of tiers of announces. If the client is compatible with the multitracker specification, and if the "announce-list" key is present, the client will ignore the "announce" key and only use the URLs in "announce-list".
  • Loading branch information
josecelano committed Nov 30, 2022
1 parent 309e141 commit f620e05
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/upgrades/from_v1_0_0_to_v2_0_0/upgrader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ async fn transfer_torrents(
.insert_torrent(&TorrentRecordV2::from_v1_data(
torrent,
&torrent_from_file.info,
&uploader
&uploader,
))
.await
.unwrap();
Expand Down Expand Up @@ -378,21 +378,7 @@ async fn transfer_torrents(
&torrent.torrent_id
);

if torrent_from_file.announce.is_some() {
println!("[v2][torrust_torrent_announce_urls][announce] adding the torrent announce url for torrent id {:?} ...", &torrent.torrent_id);

let announce_url_id = dest_database
.insert_torrent_announce_url(
torrent.torrent_id,
&torrent_from_file.announce.unwrap(),
)
.await;

println!(
"[v2][torrust_torrent_announce_urls][announce] torrent announce url insert result {:?} ...",
&announce_url_id
);
} else if torrent_from_file.announce_list.is_some() {
if torrent_from_file.announce_list.is_some() {
// BEP-0012. Multiple trackers.

println!("[v2][torrust_torrent_announce_urls][announce-list] adding the torrent announce url for torrent id {:?} ...", &torrent.torrent_id);
Expand All @@ -415,6 +401,20 @@ async fn transfer_torrents(

println!("[v2][torrust_torrent_announce_urls][announce-list] torrent announce url insert result {:?} ...", &announce_url_id);
}
} else if torrent_from_file.announce.is_some() {
println!("[v2][torrust_torrent_announce_urls][announce] adding the torrent announce url for torrent id {:?} ...", &torrent.torrent_id);

let announce_url_id = dest_database
.insert_torrent_announce_url(
torrent.torrent_id,
&torrent_from_file.announce.unwrap(),
)
.await;

println!(
"[v2][torrust_torrent_announce_urls][announce] torrent announce url insert result {:?} ...",
&announce_url_id
);
}
}
println!("Torrents transferred");
Expand Down

0 comments on commit f620e05

Please sign in to comment.