-
-
Notifications
You must be signed in to change notification settings - Fork 629
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
No examples of bootstrapping a torrent from a file on disk. #218
Comments
Have you seed |
Yup, turns out it was a mismatch between where I was placing the file and where the library expected it. TBH there isn't a way to easily make a valid torrent instances from an IO source, which would vastly simply alot of code. |
Do you mean the BuildFromFilePath? Creating torrents hasn't really been a focus for me with the repo, I've been using torrents already made. The documentation isn't clear on it, but if you set up PieceLength and Files or Name correctly, you can call Info.GeneratePieces with a callback that provides a ReadCloser to fill the hashes in Pieces. https://godoc.org/github.com/anacrolix/torrent/metainfo#Info.GeneratePieces, which is used by BuildFromFilePath internally. I'm open to better interface suggestions to match your requirements. There's also github.com/anacrolix/torrent/cmd/torrent-create to create a metainfo externally. |
I'd appreciate PRs for docs/comments to help others who might run into the original issue here you described. |
I've improved some of the documentation around the metainfo.Info methods. |
Yes, I was referring to BuildFromFilePath. here are my initial thoughts when dealing with the library the other day. first I'd remove most of the torrent related methods off the client. func (cl *Client) AddMagnet(uri string) (T *Torrent, err error) {}
func (cl *Client) AddTorrentFromFile(filename string) (T *Torrent, err error) {}
func (cl *Client) AddTorrent(mi *metainfo.MetaInfo) (T *Torrent, err error) {}
func (cl *Client) AddTorrentInfoHash(infoHash metainfo.Hash) (t *Torrent, new bool) {}
func (cl *Client) AddTorrentInfoHashWithStorage(infoHash metainfo.Hash, specStorage storage.ClientImpl) (t *Torrent, new bool) {}
func (cl *Client) AddTorrentSpec(spec *TorrentSpec) (t *Torrent, new bool, err error) {} I would likely remove all of them except for AddTorrent, I'd expose DropTorrent instead of having it on the torrent structure: func (cl *Client) AddTorrent(T *TorrentSpec) (new bool, err error) {}
func (cl *Client) DropTorrent(T *TorrentSpec) error {}
I would add the following helper methods that generate torrent specs. type TorrentSpecOption func(*TorrentSpec)
// TorrentSpecData provide the source data to the torrent, nil can represent no local data.
type TorrentSpecData(d TorrentImpl) TorrentSpecOption {
return func(t *TorrentSpec) {
t.TorrentImpl = d
}
}
// New create a torrent from the metainfo.Info and any additional options.
func New(mi metainfo.Info, options ...TorrentSpecOption) (*TorrentSpec, error) {}
// NewFromData creates a torrent from the raw data the torrent will represent.
func NewFromData(r io.Reader, options ...TorrentSpecOption) (*TorrentSpec, error) {}
// NewFromFile convience method to create a torrent from a file. see NewFromData for
// more information.
func NewFromFile(path string, options ...TorrentSpecOption) (*TorrentSpec, err error) {}
// NewFromMetadata creates a torrent from metadata stored in a file based format.
func NewFromMetadata(r io.ReadCloser, options ...TorrentSpecOption) (*TorrentSpec, error) {}
// NewFromMagnet create a torrent from a magnet URL.
func NewFromMagnet(s string, options ...TorrentSpecOption) (*TorrentSpec, error) {} |
Let's open another issue for redesign of the API. What's the status of this issue? Do you still think the documentation needs improving? |
But where is the example of bootstrapping a torrent from a file on disk now? |
But where's the real local file or dir setting? |
@TongxiJi full path to torrent file as an argument. |
@TongxiJi I think you want to seed files directly from the filesystem, and have a torrent file created for it on the fly? Open an issue if it's something like this, it would make a great example cmd. |
@anacrolix Yes,i wana a example about that.I opened a new issue here #300. |
I've spent all day trying to figure out how to take a binary file on disk and seed it to other nodes without the use of a tracker.
it seems like the other nodes block because the source node doesn't think it has the parts....
calling tor.BytesCompleted() returns 0 on the source node.
a working example that demonstrates how to load a file from disk and have it be seeded to other nodes would be a huge help.
based on some of your comments in other issues it seems like the assumption here is that a torrent always bootstraps from a remote endpoint.
The text was updated successfully, but these errors were encountered: