bitmagnet-io / bitmagnet

A self-hosted BitTorrent indexer, DHT crawler, content classifier and torrent search engine with web UI, GraphQL API and Servarr stack integration.
https://bitmagnet.io/
MIT License
2.06k stars 78 forks source link

Exclude common padding files from torrent_files #166

Open Send8213 opened 3 months ago

Send8213 commented 3 months ago

Is your feature request related to a problem? Please describe

BEP47 (padding) and BEP52 (V2) support adding padding files to torrents to ensure that files start at piece boundaries and pieces do not contain parts of more than one file. For backwards compatibility, these padding files are included in the torrent but should be ignored by modern clients and treated as full of all zeros.

Describe the solution you'd like

Do not store file information for these padding files.

Describe alternatives you've considered

Ignoring the padding files when viewing a torrent's files in Bitmagnet.

Additional context

Padding files and extended file attributes: http://bittorrent.org/beps/bep_0047.html :

The recommended path is [".pad", "N"] where N is the length of the padding file in base10.

e.g.: .pad/1 .pad/2

The BitTorrent Protocol Specification v2 http://bittorrent.org/beps/bep_0052.html :

For interoperability with BEP 3 a torrent can be created to contain the necessary data for both formats. To do so the 'pieces' field and 'files' or 'length' in the info dictionary must be generated to describe the same data in the same order. Since the old format did not align files to piece boundaries a multifile torrent must use BEP 47 padding files to achieve identical alignment.

Send8213 commented 3 months ago

Forgot to mention this from BEP47:

attr A variable-length string. When present the characters each represent a file attribute. l = symlink, x = executable, h = hidden, p = padding file. Characters appear in no particular order and unknown characters should be ignored.

The padding files should be straightforward to identify with this.