From 349afeb831c4709c0878346d64c58bf7387e90f2 Mon Sep 17 00:00:00 2001 From: Kaylee <34007889+KayleePop@users.noreply.github.com> Date: Tue, 24 Apr 2018 14:03:29 -0500 Subject: Docs and tests for store destruction --- docs/api.md | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'docs') diff --git a/docs/api.md b/docs/api.md index 062343b..98bdb1c 100644 --- a/docs/api.md +++ b/docs/api.md @@ -163,12 +163,14 @@ destroyed and all torrents are removed and cleaned up when this occurs. Always listen for the 'error' event. -## `client.remove(torrentId, [function callback (err) {}])` +## `client.remove(torrentId, [opts], [function callback (err) {}])` -Remove a torrent from the client. Destroy all connections to peers and delete all saved -file data. If `callback` is specified, it will be called when file data is removed. +Remove a torrent from the client. Destroy all connections to peers and delete all saved file metadata. -*Note: This method does not currently delete torrent data (in e.g. `/tmp/webtorrent/...`, see the `path` option to `client.add`). Until this is fixed, please implement it yourself (consider using the `rimraf` npm package). +If `opts.destroyStore` is truthy, `store.destroy()` will be called, which will delete the torrent's files from the disk. + +If `callback` is provided, it will be called when the torrent is fully destroyed, +i.e. all open sockets are closed, and the storage is either closed or destroyed. ## `client.destroy([function callback (err) {}])` @@ -319,11 +321,14 @@ Author of the torrent (string). A comment optionnaly set by the author (string). -## `torrent.destroy([callback])` +## `torrent.destroy([opts], [callback])` + +Remove the torrent from its client. Destroy all connections to peers and delete all saved file metadata. + +If `opts.destroyStore` is truthy, `store.destroy()` will be called, which will delete the torrent's files from the disk. -Alias for `client.remove(torrent)`. If `callback` is provided, it will be called when -the torrent is fully destroyed, i.e. all open sockets are closed, and the storage is -closed. +If `callback` is provided, it will be called when the torrent is fully destroyed, +i.e. all open sockets are closed, and the storage is either closed or destroyed. ## `torrent.addPeer(peer)` -- cgit v1.2.3