diff options
author | KayleePop <34007889+KayleePop@users.noreply.github.com> | 2018-08-26 22:53:56 +0300 |
---|---|---|
committer | KayleePop <34007889+KayleePop@users.noreply.github.com> | 2020-04-15 06:01:47 +0300 |
commit | 3393e92166d7049dc84e2d488b4769c668ee3b20 (patch) | |
tree | 0791d3c82d0f81f221c7a44193521ed0e3d0b087 /lib | |
parent | 349afeb831c4709c0878346d64c58bf7387e90f2 (diff) |
implement store destruction option
Diffstat (limited to 'lib')
-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 4ee7a80..689d5ef 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) + } }) } |