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

Improve compatibility BEP47 torrents #688

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

alanmcgovern
Copy link
Owner

If padding is unnecessarily applied to the last file in the torrent, do not strip it out.

As padding is not explicitly specified in the BitTorrent V2 file information, MonoTorrent uses the heuristic "pad the current file such that the next file begins at a piece boundary", which means the final file has no padding. As long as the v1 piece hash information has no padding, this is all good and the sanity checks which make sure V1 and V2 metadata match all succeed.

However, if padding is assumed to be zero for the final file when parsing the v2 file tree, and the v1 file tree has a padding file as the last entry in the torrent, then there'll be a mismatch and the torrent won't load.

This fixes the issue by just copying the padding value applied to the last file in the V1 metadata to the last file in the v2 metadata.

This allows things to hashcheck correctly.

If padding is unnecessarily applied to the last file in the torrent, do
not strip it out.

As padding is not explicitly specified in the BitTorrent V2 file
information, MonoTorrent uses the heuristic "pad the current file such
that the next file begins at a piece boundary", which means the final
file has no padding. As long as the v1 piece hash information has no
padding, this is all good and the sanity checks which make sure V1 and
V2 metadata match all succeed.

However, if padding is *assumed* to be zero for the final file when
parsing the v2 file tree, and the v1 file tree has a padding file as the
last entry in the torrent, then there'll be a mismatch and the torrent
won't load.

This fixes the issue by just copying the padding value applied to the
last file in the V1 metadata to the last file in the v2 metadata.

This allows things to hashcheck correctly.
@alanmcgovern alanmcgovern changed the title Improve compatibility (arguably incorrect) BEP47 torrents Improve compatibility BEP47 torrents Aug 28, 2024
@alanmcgovern alanmcgovern merged commit e60b1c8 into master Aug 28, 2024
0 of 2 checks passed
@alanmcgovern alanmcgovern deleted the improve-bep47-compatibility branch August 28, 2024 07:06
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