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

Serialization no longer changes torrent hash. #253

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

valdisxp1
Copy link
Contributor

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:

  1. Saving whether the torrent is private or not. TorrentSerializer places a info.private=1 only if the torrent is private otherwise it does not include that key. On the other hand, the newer MetadataBuilder would always include that key and put either a 0 or 1 depending if it private or not.
    According to bep_0027 :

When generating a metainfo file, users denote a torrent as private by including the key-value pair "private=1" in the "info" dict of the torrent's metainfo file

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. TorrentSerializer treated 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 in testMultiFileModeWithOneFileSameName where fileName == directoryName. There is a difference between abc and abc/abc.
Previously getDirectoryName could also return the file name in single-file mode. Then it should be simply getName.

If you find any value in this pull request please tag it with hacktoberfest-accepted so I get credit towards the https://hacktoberfest.digitalocean.com/ event.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant