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.
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.