Serialization no longer changes torrent hash.#253
Open
valdisxp1 wants to merge 6 commits into
Open
Conversation
according to bep_0027 the "private=1" should be included to denote private torrent, but there is nothing about "private=0", so I assume we can omit it like in the serializer
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Repeatedly serializing and de-serializing no longer changes the torrent hash. This can create hard to debug issues when saving, loading or transmitting
TorrentMetadata. "Let's save the torrent. It is saved. But where is it? (I cannot find it by the hash.)"There are two issues:
TorrentSerializerplaces ainfo.private=1only if the torrent is private otherwise it does not include that key. On the other hand, the newerMetadataBuilderwould always include that key and put either a0or1depending if it private or not.According to bep_0027 :
There is nothing about "private=0", so I assume we can omit it like in the serializer.
2. Single file torrents described in a multi-file format. This has a valid use case like giving the file a custom path like in
testMultiFileModeWithOneFile.TorrentSerializertreated a single file in multi-file mode a one in single-file mode. It did not have enough information to distinguish between the two case in scenario like intestMultiFileModeWithOneFileSameNamewherefileName == directoryName. There is a difference betweenabcandabc/abc.Previously
getDirectoryNamecould also return the file name in single-file mode. Then it should be simplygetName.If you find any value in this pull request please tag it with
hacktoberfest-acceptedso I get credit towards the https://hacktoberfest.digitalocean.com/ event.