From f19e801c66a4f7da2e636edcff0419453e6aa701 Mon Sep 17 00:00:00 2001 From: Jose Celano Date: Wed, 20 Sep 2023 17:25:41 +0100 Subject: [PATCH] refactor: [#276] extract fn Torrent::import_torrent_statistics_from_tracker --- src/services/torrent.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/services/torrent.rs b/src/services/torrent.rs index 7419cfd9..40a42179 100644 --- a/src/services/torrent.rs +++ b/src/services/torrent.rs @@ -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 @@ -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