mafintosh/torrent-stream — pull request #35 by galedric (2014-05-09 13:57:04+00:00)
Title: More precise engine.remove()

Commit 4769bbf6e96e105ec78fedff53ae1609a7a06003 intended to allow sharing the buffer directory between multiple torrent-stream instances.

On the name conflict side, for both torrent cache and data, this should be OK. However the cleanup logic in `engine.remove()` is very simple and doesn't bother to check if the removed files are related to the torrent or not.

By moving this to the storage module, we can now be a bit smarter and delete only files related our torrent.
*Note: torrent cache file itself is still unliked from index.js since it is created there.*

Also, the function does no longer attempt to delete the temporary folder itself. The idea behind this is that you can now use any directory as the buffer folder, like cwd, if the idea is to download torrent data in it (and then keep it). Maybe an option for this?

Finally, I'm not sure if torrents are guaranteed to have at most one top-level directory. If this is the case, handling multiple `roots` is not required and the code can be simplified.

In other words, you can have:
```
single.file
```
or
```
a
|_ b
| |_ ...
|_ c
|_ ...
```
but not
```
b
|_ ...
c
|_ ...
```
without a common ancestor, in one torrent.