Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resuming torrents with file metadata #1330

Closed
abhishek4695 opened this issue Mar 8, 2018 · 1 comment
Closed

Resuming torrents with file metadata #1330

abhishek4695 opened this issue Mar 8, 2018 · 1 comment

Comments

@abhishek4695
Copy link

@abhishek4695 abhishek4695 commented Mar 8, 2018

Hello, I don't know if this is the right place to ask this.

I'm trying to develop a mobile client for webtorrent using cordova. So far the only issue I'm running into is resuming seeded torrents after the app is closed.

I've solved this by using file.getBuffer and then stringifying the buffer along with the seeded file's name and mime type and then re-seeding the torrent at startup of the app by creating a new File using the constructor new File(buffer, name[, options]) and using client.seed with the created file.

This technically works but there is an inherent flaw in the process as the stringifyed object is stored in local storage of the device as a JSON file and every time a new file is seeded the JSON file's size increases. So, using this is not very practical and would require deleting the original file from the user's storage to balance the space out which is quite inconvenient.

Since I'm not on node and cordova is basically a browser window wrapped in a mobile app, I cannot seed with file path.

Is there any other way to make this work? I'm a student and I'm not very experienced with javascript, If anyone could point me in the right direction I'd be grateful.

Thanks

@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Mar 8, 2018

If you're using Cordova, do you have access to the user's filesystem?

If so, you can use the same approach as you'd do in Node.js, which is to re-add the torrent with client.add and make sure to specify the same value for opts.path. Then, WebTorrent will check that file, verify it, and continue downloading from the place it left off.

@feross feross closed this Mar 8, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.