Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow for progress on write #1788

Open
wants to merge 3 commits into
base: master
from
Open
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -114,6 +114,8 @@ class Torrent extends EventEmitter {
this._servers = []
this._xsRequests = []

this._writeCb = opts.writeCb

// TODO: remove this and expose a hook instead
// optimization: don't recheck every file if it hasn't changed
this._fileModtimes = opts.fileModtimes
@@ -1597,7 +1599,14 @@ class Torrent extends EventEmitter {
if (!cb) cb = noop

const readable = new MultiStream(streams)
let read = 0
const writable = new ChunkStoreWriteStream(this.store, this.pieceLength)
if (this._writeCb) {
writable._blockstream.on('data', data => {
read += data.length
this._writeCb(this.length, read)
})
}

pump(readable, writable, err => {
if (err) return cb(err)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.