fix: Wrong infohash when info dict contains source field #249
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theinfo
key.This PR adds the missing field.
TODO
Improvements
TorrentInfo
values.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 ajson
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:
Info dict key with a multiple files: