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 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Next

allow for progress on write

  • Loading branch information
ftreesmilo committed Dec 10, 2019
commit 6c9d48c5da6fb94d10cbb206eb445349eeacb065
@@ -113,6 +113,8 @@ class Torrent extends EventEmitter {
// for cleanup
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
@@ -1597,7 +1599,11 @@ 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 => this._writeCb(this.length, read += data.length))
}

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.