Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for v2 torrents in create_torrent, but keep the old default of only adding the v1 metadata. Unify the single-file and directory cases to avoid code duplication. V2 torrents require files to be piece-aligned. The same for hybrid v1/v2 ones. To handle both cases of piece-aligned and non-aligned files, always read the files in piece-aligned chunks. Re-slice the buffer if needed (for v1-only multi-file torrents). Also, had to adapt to progress event. It now depends on the number of bytes hashed rather than the number of pieces. To avoid sending and excessive amount of event when handling a directory with many small files, add a mechanism to limit event period at 1 per piece_length.
- Loading branch information