Skip to content

Commit

Permalink
refactor: [torrust#276] extract fn Torrent::import_torrent_statistics…
Browse files Browse the repository at this point in the history
…_from_tracker
  • Loading branch information
josecelano committed Sep 20, 2023
1 parent fbb42ad commit f19e801
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/services/torrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,10 @@ impl Index {
.add(&original_info_hash, &torrent, &metadata, user_id)
.await?;

// Secondary task: import torrent statistics from the tracker
// Synchronous secondary tasks

drop(
self.tracker_statistics_importer
.import_torrent_statistics(torrent_id, &torrent.canonical_info_hash_hex())
.await,
);
self.import_torrent_statistics_from_tracker(torrent_id, &torrent.canonical_info_hash())
.await;

// Secondary task: whitelist torrent on the tracker

Expand Down Expand Up @@ -239,6 +236,14 @@ impl Index {
torrent.reset_announce_list_if_private();
}

async fn import_torrent_statistics_from_tracker(&self, torrent_id: TorrentId, canonical_info_hash: &InfoHash) {
drop(
self.tracker_statistics_importer
.import_torrent_statistics(torrent_id, &canonical_info_hash.to_hex_string())
.await,
);
}

/// Gets a torrent from the Index.
///
/// # Errors
Expand Down

0 comments on commit f19e801

Please sign in to comment.