use of com.acgist.snail.protocol.magnet.TorrentBuilder in project snail by acgist.
the class TorrentSession method saveTorrent.
/**
* <p>保存种子文件</p>
* <p>重新并加载种子文件和InfoHash</p>
*/
public void saveTorrent() {
final TorrentBuilder builder = TorrentBuilder.newInstance(this.infoHash, this.trackerLauncherGroup.trackers());
final String torrentFilePath = builder.buildFile(this.taskSession.downloadFolder().getAbsolutePath());
try {
this.torrent = TorrentContext.loadTorrent(torrentFilePath);
this.infoHash = this.torrent.infoHash();
} catch (DownloadException e) {
LOGGER.error("加载种子异常:{}", torrentFilePath, e);
}
final long torrentFileSize = FileUtils.fileSize(torrentFilePath);
this.taskSession.setTorrent(torrentFilePath);
this.taskSession.setSize(torrentFileSize);
this.taskSession.downloadSize(torrentFileSize);
this.taskSession.update();
this.checkCompletedAndDone();
}
Aggregations