Skip to content

Commit d56d66c

Browse files
committed
refactor: [#615] download torrent handler now calls the torrent service to get the canonical infohash
1 parent b3ffc9f commit d56d66c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/web/api/server/v1/contexts/torrent/handlers.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ pub async fn download_torrent_handler(
7777

7878
debug!("Downloading torrent: {:?}", info_hash.to_hex_string());
7979

80-
if let Some(redirect_response) = redirect_to_download_url_using_canonical_info_hash_if_needed(&app_data, &info_hash).await {
80+
if let Some(redirect_response) =
81+
redirect_to_download_url_using_canonical_info_hash_if_needed(&app_data, &info_hash, opt_user_id).await
82+
{
8183
debug!("Redirecting to URL with canonical info-hash");
8284
redirect_response
8385
} else {
@@ -101,12 +103,9 @@ pub async fn download_torrent_handler(
101103
async fn redirect_to_download_url_using_canonical_info_hash_if_needed(
102104
app_data: &Arc<AppData>,
103105
info_hash: &InfoHash,
106+
opt_user_id: Option<i64>,
104107
) -> Option<Response> {
105-
match app_data
106-
.torrent_info_hash_repository
107-
.find_canonical_info_hash_for(info_hash)
108-
.await
109-
{
108+
match app_data.torrent_service.get_canonical_info_hash(info_hash, opt_user_id).await {
110109
Ok(Some(canonical_info_hash)) => {
111110
if canonical_info_hash != *info_hash {
112111
return Some(

0 commit comments

Comments
 (0)