Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix different info-hashes for uploaded and downloaded torrents #286

Merged
merged 3 commits into from
Sep 13, 2023
Merged

Fix different info-hashes for uploaded and downloaded torrents #286

merged 3 commits into from
Sep 13, 2023

Conversation

josecelano
Copy link
Member

@josecelano josecelano commented Sep 13, 2023

If you upload a torrent and you download it, the downloaded torrent info-hash is not the same if the origin one didn't contain the private field in the info dictionary. The Index always includes that field in the response because it always stores a TRUE or FALSE value in the database, even when the field is not in the original torrent file.

  • Fix the test. It was passing with a different info-hash for no reason. It should fail with the current implementation.
  • Change the handler to set private to NULL when not in the original torrent. And do not include it in the response when it's NULL in the database.
  • Refactor all tests using the e2e::web::api::v1::contexts::torrent::asserts::expected_torrent function to compare the info-hashes.

The test for downloading a torrent now compares the uplaoded torrent
info-hash with the downloaded one. It fails becuasse the Index adds the
`private` field in the `info` dictioanry always, changing the info-hash.
@josecelano josecelano temporarily deployed to coverage September 13, 2023 12:43 — with GitHub Actions Inactive
@josecelano josecelano temporarily deployed to coverage September 13, 2023 12:43 — with GitHub Actions Inactive
@josecelano josecelano temporarily deployed to coverage September 13, 2023 13:11 — with GitHub Actions Inactive
@josecelano josecelano temporarily deployed to coverage September 13, 2023 13:13 — with GitHub Actions Inactive
NOTICE: They only matche when the index doesn't change it becuase it
removs non-standard fields from the `info` key dictionary. They should
match if the uploaded torrent does not have any non-stanrdard field in
the `info` dictionary key.
@josecelano josecelano temporarily deployed to coverage September 13, 2023 13:19 — with GitHub Actions Inactive
@josecelano josecelano temporarily deployed to coverage September 13, 2023 13:19 — with GitHub Actions Inactive
@codecov-commenter
Copy link

codecov-commenter commented Sep 13, 2023

Codecov Report

Merging #286 (d7cc040) into develop (b73e19e) will not change coverage.
The diff coverage is 40.00%.

@@           Coverage Diff            @@
##           develop     #286   +/-   ##
========================================
  Coverage    43.65%   43.65%           
========================================
  Files           77       77           
  Lines         4240     4240           
========================================
  Hits          1851     1851           
  Misses        2389     2389           
Files Changed Coverage Δ
src/databases/mysql.rs 0.00% <0.00%> (ø)
src/databases/sqlite.rs 22.32% <0.00%> (ø)
src/models/torrent_file.rs 80.37% <50.00%> (ø)
src/services/torrent_file.rs 100.00% <100.00%> (ø)

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

@josecelano josecelano temporarily deployed to coverage September 13, 2023 15:12 — with GitHub Actions Inactive
@josecelano josecelano temporarily deployed to coverage September 13, 2023 15:12 — with GitHub Actions Inactive
@josecelano josecelano temporarily deployed to coverage September 13, 2023 15:14 — with GitHub Actions Inactive
@josecelano josecelano temporarily deployed to coverage September 13, 2023 15:14 — with GitHub Actions Inactive
@josecelano josecelano marked this pull request as ready for review September 13, 2023 15:50
@josecelano
Copy link
Member Author

ACK d7cc040

@josecelano josecelano merged commit 92e844c into torrust:develop Sep 13, 2023
9 checks passed
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.

Downloaded torrent info-hash does not match uploaded torrent info-hash
2 participants