1

私は、electron と webtorrent を使って小さな torrent クライアントを作成しようとしています。最初はすべて問題ないように見えますが、トレントのダウンロードが完了したときに、結果のファイルがディスクに書き込まれないことがあります。

私のプロジェクトは、SimulatedGREG/electron-vue ボイラープレートを介してセットアップされます。

ここに私のトレントクライアントクラスのコードがあります:

const WebTorrent = require('webtorrent');
const client = new WebTorrent();  
export default class TorrentClient {
  download (downloadInfo) {
    console.log('download torrent from magnet link:', downloadInfo.magnetLink);

    let torrent = client.add(downloadInfo.infoHash);
    torrent.on('download', function (bytes) {
      console.log('just downloaded: ' + bytes);
      console.log('total downloaded: ' + torrent.downloaded);
      console.log('download speed: ' + torrent.downloadSpeed);
      console.log('progress: ' + torrent.progress);
    });
    torrent.on('done', function () {
      console.log('done...');
    });
  }
}
4

2 に答える 2