Skip to content

Commit f620e05

Browse files
committed
fix: [#56] announce list has precedence over announce
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".
1 parent 309e141 commit f620e05

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/upgrades/from_v1_0_0_to_v2_0_0/upgrader.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ async fn transfer_torrents(
289289
.insert_torrent(&TorrentRecordV2::from_v1_data(
290290
torrent,
291291
&torrent_from_file.info,
292-
&uploader
292+
&uploader,
293293
))
294294
.await
295295
.unwrap();
@@ -378,21 +378,7 @@ async fn transfer_torrents(
378378
&torrent.torrent_id
379379
);
380380

381-
if torrent_from_file.announce.is_some() {
382-
println!("[v2][torrust_torrent_announce_urls][announce] adding the torrent announce url for torrent id {:?} ...", &torrent.torrent_id);
383-
384-
let announce_url_id = dest_database
385-
.insert_torrent_announce_url(
386-
torrent.torrent_id,
387-
&torrent_from_file.announce.unwrap(),
388-
)
389-
.await;
390-
391-
println!(
392-
"[v2][torrust_torrent_announce_urls][announce] torrent announce url insert result {:?} ...",
393-
&announce_url_id
394-
);
395-
} else if torrent_from_file.announce_list.is_some() {
381+
if torrent_from_file.announce_list.is_some() {
396382
// BEP-0012. Multiple trackers.
397383

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

416402
println!("[v2][torrust_torrent_announce_urls][announce-list] torrent announce url insert result {:?} ...", &announce_url_id);
417403
}
404+
} else if torrent_from_file.announce.is_some() {
405+
println!("[v2][torrust_torrent_announce_urls][announce] adding the torrent announce url for torrent id {:?} ...", &torrent.torrent_id);
406+
407+
let announce_url_id = dest_database
408+
.insert_torrent_announce_url(
409+
torrent.torrent_id,
410+
&torrent_from_file.announce.unwrap(),
411+
)
412+
.await;
413+
414+
println!(
415+
"[v2][torrust_torrent_announce_urls][announce] torrent announce url insert result {:?} ...",
416+
&announce_url_id
417+
);
418418
}
419419
}
420420
println!("Torrents transferred");

0 commit comments

Comments
 (0)