File indices are miscalculated for v2 files (BEP 0053) (original) (raw)

Please provide the following information

libtorrent version (or branch):
2.0.8.0
platform/architecture:
win/64
compiler and compiler version:
boost/1.81.0

When using file indices for v2 torrents, libtorrent will fail to set them correspondingly.

Adding f.e. &so=0,5,7 to the magnet link, won't set downloading of those files corresponding to file tree metadata, since there's no files list.
For hybrid and v2 only files file indices could be calculated using file tree list instead of files, since it has no piece alignment files.

Currently I'm in the process of making of the tool to get rid of duplicate files before downloading via magnet links for v2/hybrid .torrent files, to my regret I can't use this feature as thought, maybe there's a workaround?

Tests:

This magnet link will set downloading status only for the first file for attached torrent. 5th and 7th indices won't be set.
Also if magnet metadata will fetch before saving torrent to client, it will download all files, regardless of what we passed in &so parameter.

magnet:?xt=urn:btmh:1220bb994bde0d68f3a9e5e6855ae901874d7511770785b40ef1dbae9256bea0be1d&dn=test&tr=&so=0,5,7

indices
qbittorrent_window

test.torrent.zip