mpetazzoni / ttorrent

BitTorrent Java library with tracker and download client
http://mpetazzoni.github.com/ttorrent/
Apache License 2.0
1.39k stars 502 forks source link

Web-Seeds not fully implemented #271

Open Finomosec opened 2 months ago

Finomosec commented 2 months ago

Hi there,

you added "support" for Web-Seeds here: https://github.com/mpetazzoni/ttorrent/pull/240/commits/ebb5c29149bd6b7afcd8184ba2c40e408f0d2e3b

But you forgot to add it in (at least) TorrentMetadata and TorrentSerializer, so the info gets lost, when doing this:

private void makeTorrent(File torrentFile) {
    final var builder = new MetadataBuilder();
    // builder.setXYZ(...);
    saveTorrent(builder.build(), torrentFile);
}

private void saveTorrent(TorrentMetadata torrent, Path file) throws IOException {
    try (FileOutputStream fos = new FileOutputStream(file.toFile())) {
        fos.write(new TorrentSerializer().serialize(torrent));
    }
}

The WebSeeds are missing in the saved torrent file.