Skip to content

Redirect to URL with canonical info-hash#281

Merged
josecelano merged 3 commits intotorrust:developfrom
josecelano:issue-278-redirect-to-canonical-infohash
Sep 13, 2023
Merged

Redirect to URL with canonical info-hash#281
josecelano merged 3 commits intotorrust:developfrom
josecelano:issue-278-redirect-to-canonical-infohash

Conversation

@josecelano
Copy link
Copy Markdown
Member

@josecelano josecelano commented Sep 12, 2023

For endpoints using a GET param with an infohash:

  • GET /v1/torrent/INFO_HASH
  • GET /v1/torrent/download/INFO_HASH

That param must be the canonical infohash so far. This PR allows users to use the original info-hash.

Suppose the URL contains an info-hash, which is not canonical but belongs to a canonical info-hash group. In that case, the response will be a redirection (307) to the same URL but using the canonical info-hash.

Subtasks

  • Refactor: use the new domain concept Canonical Infohash Group.
  • Add the redirection.
  • Add test for torrent details URL redirection.
  • Add test for download torrent URL redirection.

@josecelano josecelano temporarily deployed to coverage September 12, 2023 16:04 — with GitHub Actions Inactive
@josecelano josecelano temporarily deployed to coverage September 12, 2023 16:05 — with GitHub Actions Inactive
@josecelano josecelano temporarily deployed to coverage September 12, 2023 16:06 — with GitHub Actions Inactive
@josecelano josecelano temporarily deployed to coverage September 12, 2023 16:06 — with GitHub Actions Inactive
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Sep 12, 2023

Codecov Report

Merging #281 (fb3f4dd) into develop (92e844c) will decrease coverage by 0.10%.
Report is 2 commits behind head on develop.
The diff coverage is 35.18%.

@@             Coverage Diff             @@
##           develop     #281      +/-   ##
===========================================
- Coverage    43.65%   43.56%   -0.10%     
===========================================
  Files           77       77              
  Lines         4240     4320      +80     
===========================================
+ Hits          1851     1882      +31     
- Misses        2389     2438      +49     
Files Changed Coverage Δ
src/app.rs 100.00% <ø> (ø)
src/common.rs 100.00% <ø> (ø)
src/databases/database.rs 30.55% <ø> (ø)
src/databases/mysql.rs 0.00% <0.00%> (ø)
src/services/torrent.rs 19.87% <18.18%> (+0.61%) ⬆️
src/databases/sqlite.rs 22.91% <36.84%> (+0.59%) ⬆️
src/web/api/v1/contexts/torrent/handlers.rs 50.24% <49.15%> (-0.38%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@josecelano josecelano temporarily deployed to coverage September 12, 2023 17:33 — with GitHub Actions Inactive
@josecelano josecelano temporarily deployed to coverage September 12, 2023 17:33 — with GitHub Actions Inactive
@josecelano
Copy link
Copy Markdown
Member Author

I found a bug while adding the tests for the download torrent endpoint.

@josecelano josecelano requested a review from da2ce7 September 12, 2023 19:36
@josecelano josecelano temporarily deployed to coverage September 13, 2023 07:15 — with GitHub Actions Inactive
@josecelano josecelano temporarily deployed to coverage September 13, 2023 07:15 — with GitHub Actions Inactive
@josecelano josecelano temporarily deployed to coverage September 13, 2023 16:18 — with GitHub Actions Inactive
@josecelano josecelano temporarily deployed to coverage September 13, 2023 16:18 — with GitHub Actions Inactive
@josecelano
Copy link
Copy Markdown
Member Author

I found a bug while adding the tests for the download torrent endpoint.

I fixed it: #286

@josecelano josecelano marked this pull request as ready for review September 13, 2023 16:50
@josecelano
Copy link
Copy Markdown
Member Author

josecelano commented Sep 13, 2023

ACK 2a73f10

For endpoints using a GET param with an infohash:

- GET /v1/torrent/CANONICAL_INFO_HASH
- GET /v1/torrent/download/CANONICAL_INFO_HASH

Suppose the URL contains an info-hash, which is not canonical but belongs to a canonical info-hash group. In that case, the response will be a redirection (307) to the same URL but using the canonical info-hash.
@josecelano josecelano temporarily deployed to coverage September 13, 2023 16:59 — with GitHub Actions Inactive
@josecelano josecelano temporarily deployed to coverage September 13, 2023 16:59 — with GitHub Actions Inactive
@josecelano josecelano merged commit f904f14 into torrust:develop Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

On the torrent details endpoint redirect to the canonical info-hash if other original info-hash is used

2 participants