Skip to content

Commit

Permalink
refactor: [#615] download torrent handler now calls the torrent servi…
Browse files Browse the repository at this point in the history
…ce to get the canonical infohash
  • Loading branch information
mario-nt committed Aug 3, 2024
1 parent b3ffc9f commit d56d66c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/web/api/server/v1/contexts/torrent/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ pub async fn download_torrent_handler(

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

if let Some(redirect_response) = redirect_to_download_url_using_canonical_info_hash_if_needed(&app_data, &info_hash).await {
if let Some(redirect_response) =
redirect_to_download_url_using_canonical_info_hash_if_needed(&app_data, &info_hash, opt_user_id).await
{
debug!("Redirecting to URL with canonical info-hash");
redirect_response
} else {
Expand All @@ -101,12 +103,9 @@ pub async fn download_torrent_handler(
async fn redirect_to_download_url_using_canonical_info_hash_if_needed(
app_data: &Arc<AppData>,
info_hash: &InfoHash,
opt_user_id: Option<i64>,
) -> Option<Response> {
match app_data
.torrent_info_hash_repository
.find_canonical_info_hash_for(info_hash)
.await
{
match app_data.torrent_service.get_canonical_info_hash(info_hash, opt_user_id).await {
Ok(Some(canonical_info_hash)) => {
if canonical_info_hash != *info_hash {
return Some(
Expand Down

0 comments on commit d56d66c

Please sign in to comment.