-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #249: fix: Wrong infohash when info dict contains source field
8fe0955 fix: clippy warning (Jose Celano) bc04231 doc: [#242] improve infohash generation documentaion (Jose Celano) 6fc4050 test: [#242] add tests for infohash calculation (Jose Celano) c3e61ea fix: [#242] wrong infohash when info dict contains source field (Jose Celano) Pull request description: When you define a "source" field value in the "info" dictionary inside the torrent file, that field changes the torrent infohash value. We did not save that field in the database and in the in-memory struct `TorrentInfo`, so the calculated infohash was wrong because this field belongs to the `info` key. This PR adds the missing field. ### TODO - [x] Test with MySQL - [x] Update the documentation about how infohashes are calculated ### Improvements - [x] Add tests for the infohash calculation with different examples of `TorrentInfo` values. - [ ] The `TorrentInfo` struct should be explicit about the two types of torrents: single file or multiple file. See: https://wiki.theory.org/BitTorrentSpecification#Info_in_Single_File_Mode ### Other considerations I have not found any BEP describing this source key in the info dictionary. There could be more non-official fields. Maybe instead of adding a hardcoded field in the `torrust_torrent` table, we should add a `json` value or something that allows us to save all the extra non-official fields, but I have not seen any other. What do you think @da2ce7? ### Extra Info dict key with a single file: ```json { "length": 172204, "name": "mandelbrot_2048x2048.png", "piece length": 16384, "pieces": "<hex>7D 91 71 0D 9D 4D BA 88 9B 54 20 54 D5 26 72 8D 5A 86 3F E1 21 DF 77 C7 F7 BB 6C 77 96 21 66 25 38 C5 D9 CD AB 8B 08 EF 8C 24 9B B2 F5 C4 CD 2A DF 0B C0 0C F0 AD DF 72 90 E5 B6 41 4C 23 6C 47 9B 8E 9F 46 AA 0C 0D 8E D1 97 FF EE 68 8B 5F 34 A3 87 D7 71 C5 A6 F9 8E 2E A6 31 7C BD F0 F9 E2 23 F9 CC 80 AF 54 00 04 F9 85 69 1C 77 89 C1 76 4E D6 AA BF 61 A6 C2 80 99 AB B6 5F 60 2F 40 A8 25 BE 32 A3 3D 9D 07 0C 79 68 98 D4 9D 63 49 AF 20 58 66 26 6F 98 6B 6D 32 34 CD 7D 08 15 5E 1A D0 00 09 57 AB 30 3B 20 60 C1 DC 12 87 D6 F3 E7 45 4F 70 67 09 36 31 55 F2 20 F6 6C A5 15 6F 2C 89 95 69 16 53 81 7D 31 F1 B6 BD 37 42 CC 11 0B B2 FC 2B 49 A5 85 B6 FC 76 74 44 93</hex>", "private": 1, "source": "Source" } ``` Info dict key with a multiple files: ```json { "files": [ { "length": 37, "path": [ "file-425ef9ca-014d-403f-8f15-3ece9e3fad38.txt" ] }, { "length": 37, "path": [ "file-deeafa50-2e25-4f38-bec0-92865ca6bb1d.txt" ] } ], "name": "dir-839a49f0-cabc-4efb-ad5f-b6fb15f8a467", "piece length": 16384, "pieces": "<hex>8E 47 18 74 52 8E 68 92 DD 86 66 F0 0B DD AD B1 08 DC 69 44</hex>", "private": 1, "source": "Source" } ``` ACKs for top commit: josecelano: ACK 8fe0955 Tree-SHA512: edbe69114ad971ce66161090243dca10ab43505c0eccc71caa9630b27e14d11df37d17e671c8767b9f95d01109ab486c18fbb7996b04744c8ea17fa4406a6d2a
- Loading branch information
Showing
8 changed files
with
317 additions
and
16 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
migrations/mysql/20230803160604_torrust_torrents_add_source.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE torrust_torrents ADD COLUMN source TEXT DEFAULT NULL |
1 change: 1 addition & 0 deletions
1
migrations/sqlite3/20230803160604_torrust_torrents_add_source.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE torrust_torrents ADD COLUMN source TEXT DEFAULT NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.