Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upfile.deselect supposedly not working #164
Comments
This comment has been minimized.
This comment has been minimized.
|
I also didn't see an option to download torrent metadata only as well as a ways to decide which files/parts should (not) be downloaded. |
This comment has been minimized.
This comment has been minimized.
|
@feross The problem is in the conditional in If you put a debug line inside the conditional and then attempt to download only particular files in a torrent via deselecting all of the files which you do not want, you will never see it -- because the conditional is never met! The issue appears to be that the conditional is trying to match the piece range of the file you wish to deselect, against the stored piece range. However, it will never find a match, as the only stored range is the piece range of the torrent in its entirety. A way to demonstrate how this is broken (and a hacky fix to get the effective functionality of You also might want to change the readme section for I did notice that unfortunately, you will get "false" copies of the files on either side of the piece range you selected, due to the nature of files not beginning or ending exactly where pieces do. This should probably be opened as a separate bug unless you can easily add in code for cleanup of those / prevent the creation of those false-files during this bugfix. Credit goes to AlliedEnvy for figuring this out. |
This comment has been minimized.
This comment has been minimized.
|
Yeah, the You have to deselect the whole torrent first, then select individual files. Here's how we made it work in WebTorrent Desktop:
@feross we should probably improve this API before WebTorrent 1.0, because afterward we don't want to change it. Is there a reason to let people deselect individual blocks within a file? What if the API only allowed selecting which files in a torrent to download? Here's an API proposalRemove the Let users specify which files they want when adding a torrent: client.add('magnet://...', { fileSelections: [true, true, false, true] })When you do that, the files that aren't selected are never created on disk. Let users specify which files they want after adding a torrent: torrent.setFileSelections([true, true, false, true])Doing that doesn't delete any files. Partially downloaded files just stay there, unless the user deletes them separately. This lets you pause and resume individual files in a torrent. This alternate API would require the library to do a bit more work to keep track of pieces overlapping a file boundary. It's simpler, though. You always declare what you want to download for the whole torrent, instead of calling |
This comment has been minimized.
This comment has been minimized.
|
Or maybe: torrent.setFileSelections([12,23]);So if a torrent have big number of files, you don't have to do [false, false, false, false, false, false, ... , true]; torrent.setFileDeselections([4,6,9]); |
This comment has been minimized.
This comment has been minimized.
|
I like the idea that @kocoten1992 has, which is how the transmission rpc is also. You define an array of wanted/unwanted file indices. Having this option when adding torrents would be amazing! |
This comment has been minimized.
This comment has been minimized.
|
Some news? |
This comment has been minimized.
This comment has been minimized.
|
I started implementing @dcposch proposal, in the fashion described by @kocoten1992, with a list of wanted files. |
This comment has been minimized.
This comment has been minimized.
@dcposch - Yes there could be. Given that torrent runs in a browser with limited storage, it might be useful to distribute storage of a single large file, eg a hi-def video, across a swarm. Therefore nodes in a swarm only download and maintain a smaller set of blocks within a file rather than the whole, providing them as needed. |
Heard from someone on IRC that after calling
file.deselecton a file, it still gets fully downloaded.