diff options
author | Kaylee <34007889+KayleePop@users.noreply.github.com> | 2020-09-10 21:38:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-10 21:38:44 +0300 |
commit | 7aee819796c540df0b247fec1853098f9a591d4c (patch) | |
tree | 6eb6ac35de0fed83e3e2470a3e647645c8bfa240 /lib/torrent.js | |
parent | 9ae31e5d8a44b98a768971efb7c6b7b386eb9447 (diff) | |
parent | 3393e92166d7049dc84e2d488b4769c668ee3b20 (diff) |
Merge pull request #1364 from KayleePop/destroy
Diffstat (limited to 'lib/torrent.js')
-rw-r--r-- | lib/torrent.js | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/torrent.js b/lib/torrent.js index 3be12af..caa6687 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -641,11 +641,14 @@ class Torrent extends EventEmitter { this._updateSelections() } - destroy (cb) { - this._destroy(null, cb) + destroy (opts, cb) { + if (typeof opts === 'function') return this.destroy(null, opts) + + this._destroy(null, opts, cb) } - _destroy (err, cb) { + _destroy (err, opts, cb) { + if (typeof opts === 'function') return this._destroy(err, null, opts) if (this.destroyed) return this.destroyed = true this._debug('destroy') @@ -682,7 +685,11 @@ class Torrent extends EventEmitter { if (this.store) { tasks.push(cb => { - this.store.close(cb) + if (opts && opts.destroyStore) { + this.store.destroy(cb) + } else { + this.store.close(cb) + } }) } |