![](/img/trans.png)
[英]Sometimes data is not getting written in the AWS S3 bucket by Lambda
[英]Why are my finished torrents (sometimes) not getting written to disk?
我尝试用电子和 webtorrent 编写一个小洪流客户端。 一开始一切似乎都很好,但有时当 torrent 下载完成时,结果文件没有写入磁盘。
我的项目是通过 SimulatedGREG/electron-vue 样板设置的。
这是我的 torrent 客户端类的代码:
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...');
});
}
}
更新:我解决了这个问题。
在我调试了 webtorrent 正在使用的 fs-chunk-store 之后,我发现在数据写入磁盘之前抛出了一个错误。 当调用 fs.mkdir 为下载目的地创建新路径时发生错误(ENOENT:没有这样的文件或目录,mkdir 'path/to/folder')。 如果没有回调函数作为参数,错误将不会打印到标准输出。
我现在的解决方案是使用 fs-chunk-store 的自定义实现,它允许递归创建文件夹。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.