Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/torrent.js')
-rw-r--r--lib/torrent.js18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/torrent.js b/lib/torrent.js
index 60f1a20..7412158 100644
--- a/lib/torrent.js
+++ b/lib/torrent.js
@@ -8,7 +8,7 @@ import path from 'path'
import addrToIPPort from 'addr-to-ip-port'
import BitField from 'bitfield'
import CacheChunkStore from 'cache-chunk-store'
-import ChunkStoreWriteStream from 'chunk-store-stream/write.js'
+import { chunkStoreWrite } from 'chunk-store-iterator'
import cpus from 'cpus'
import debugFactory from 'debug'
import Discovery from 'torrent-discovery'
@@ -22,14 +22,12 @@ import parallel from 'run-parallel'
import parallelLimit from 'run-parallel-limit'
import parseTorrent from 'parse-torrent'
import Piece from 'torrent-piece'
-import pump from 'pump'
import queueMicrotask from 'queue-microtask'
import randomIterate from 'random-iterate'
import sha1 from 'simple-sha1'
import throughput from 'throughput'
import utMetadata from 'ut_metadata'
import utPex from 'ut_pex' // browser exclude
-import { Readable } from 'streamx'
import File from './file.js'
import Peer from './peer.js'
@@ -1830,22 +1828,22 @@ export default class Torrent extends EventEmitter {
return done
}
- load (streams, cb) {
+ async load (streams, cb) {
if (this.destroyed) throw new Error('torrent is destroyed')
if (!this.ready) return this.once('ready', () => { this.load(streams, cb) })
if (!Array.isArray(streams)) streams = [streams]
if (!cb) cb = noop
- const readable = Readable.from(joinIterator(streams))
- const writable = new ChunkStoreWriteStream(this.store, this.pieceLength)
-
- pump(readable, writable, err => {
- if (err) return cb(err)
+ try {
+ await chunkStoreWrite(this.store, joinIterator(streams), { chunkLength: this.pieceLength })
this._markAllVerified()
this._checkDone()
cb(null)
- })
+ } catch (err) {
+ cb(err)
+ return err
+ }
}
pause () {