Skip to content

Commit f19e801

Browse files
committed
refactor: [#276] extract fn Torrent::import_torrent_statistics_from_tracker
1 parent fbb42ad commit f19e801

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/services/torrent.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,10 @@ impl Index {
146146
.add(&original_info_hash, &torrent, &metadata, user_id)
147147
.await?;
148148

149-
// Secondary task: import torrent statistics from the tracker
149+
// Synchronous secondary tasks
150150

151-
drop(
152-
self.tracker_statistics_importer
153-
.import_torrent_statistics(torrent_id, &torrent.canonical_info_hash_hex())
154-
.await,
155-
);
151+
self.import_torrent_statistics_from_tracker(torrent_id, &torrent.canonical_info_hash())
152+
.await;
156153

157154
// Secondary task: whitelist torrent on the tracker
158155

@@ -239,6 +236,14 @@ impl Index {
239236
torrent.reset_announce_list_if_private();
240237
}
241238

239+
async fn import_torrent_statistics_from_tracker(&self, torrent_id: TorrentId, canonical_info_hash: &InfoHash) {
240+
drop(
241+
self.tracker_statistics_importer
242+
.import_torrent_statistics(torrent_id, &canonical_info_hash.to_hex_string())
243+
.await,
244+
);
245+
}
246+
242247
/// Gets a torrent from the Index.
243248
///
244249
/// # Errors

0 commit comments

Comments
 (0)