cmd/magnet-metainfo/main.go | 4 ++-- cmd/torrent-pick/main.go | 2 +- cmd/torrent/main.go | 6 +++--- download.go | 1 + fs/torrentfs.go | 8 ++++---- diff --git a/cmd/magnet-metainfo/main.go b/cmd/magnet-metainfo/main.go index 878fc7db9404c81445c57325b9a2ce16bde88982..d3a070c0120b5cb515d2d7a24590a005a478587f 100644 --- a/cmd/magnet-metainfo/main.go +++ b/cmd/magnet-metainfo/main.go @@ -27,9 +27,9 @@ wg.Add(1) go func() { defer wg.Done() <-t.GotInfo() - mi := t.MetaInfo() + mi := t.Info() t.Drop() - f, err := os.Create(mi.Info.Name + ".torrent") + f, err := os.Create(mi.Name + ".torrent") if err != nil { log.Fatalf("error creating torrent metainfo file: %s", err) } diff --git a/cmd/torrent-pick/main.go b/cmd/torrent-pick/main.go index 928f11f4df00d16b0f7832c1e8ae7ac69e2ead54..f02ea8e7cc69656b9e422c9da4b28e10a8a671d1 100644 --- a/cmd/torrent-pick/main.go +++ b/cmd/torrent-pick/main.go @@ -134,7 +134,7 @@ dstWriter := bufio.NewWriter(f) done := make(chan struct{}) for _, arg := range posArgs { - t := func() torrent.Torrent { + t := func() torrent.Download { if strings.HasPrefix(arg, "magnet:") { t, err := client.AddMagnet(arg) if err != nil { diff --git a/cmd/torrent/main.go b/cmd/torrent/main.go index 4adda93e07cf71678e8a8a8d6764b0bc5af20448..43b75b5dbcfe72c76838839c10d3aca3e26c1072 100644 --- a/cmd/torrent/main.go +++ b/cmd/torrent/main.go @@ -36,7 +36,7 @@ } return } -func torrentBar(t torrent.Torrent) { +func torrentBar(t torrent.Download) { bar := uiprogress.AddBar(1) bar.AppendCompleted() bar.AppendFunc(func(*uiprogress.Bar) (ret string) { @@ -54,7 +54,7 @@ return fmt.Sprintf("downloading (%s/%s)", humanize.Bytes(uint64(t.BytesCompleted())), humanize.Bytes(uint64(t.Info().TotalLength()))) } }) bar.PrependFunc(func(*uiprogress.Bar) string { - return t.Name() + return t.Info().Name }) go func() { <-t.GotInfo() @@ -69,7 +69,7 @@ } func addTorrents(client *torrent.Client) { for _, arg := range opts.Torrent { - t := func() torrent.Torrent { + t := func() torrent.Download { if strings.HasPrefix(arg, "magnet:") { t, err := client.AddMagnet(arg) if err != nil { diff --git a/download.go b/download.go index b7e6095eaf4031dcf2f7c8a6731ea8d0c0eacb37..6e60af07a53c9e301c105ba039398f2d048f6771 100644 --- a/download.go +++ b/download.go @@ -22,4 +22,5 @@ Client() *Client AddPeers(pp []Peer) error DownloadAll() Trackers() [][]tracker.Client + Files() (ret []File) } \ No newline at end of file diff --git a/fs/torrentfs.go b/fs/torrentfs.go index 9b3f3958768532a1497d9befbd450a4ba2d64928..b9cb3ad70e8acacaace2930720ca612acd0deff4 100644 --- a/fs/torrentfs.go +++ b/fs/torrentfs.go @@ -50,7 +50,7 @@ type node struct { path string metadata *metainfo.Info FS *TorrentFS - t torrent.Torrent + t torrent.Download } type fileNode struct { @@ -69,7 +69,7 @@ func (n *node) fsPath() string { return "/" + n.metadata.Name + "/" + n.path } -func blockingRead(ctx context.Context, fs *TorrentFS, t torrent.Torrent, off int64, p []byte) (n int, err error) { +func blockingRead(ctx context.Context, fs *TorrentFS, t torrent.Download, off int64, p []byte) (n int, err error) { fs.mu.Lock() fs.blockedReads++ fs.event.Broadcast() @@ -101,7 +101,7 @@ fs.mu.Unlock() return } -func readFull(ctx context.Context, fs *TorrentFS, t torrent.Torrent, off int64, p []byte) (n int, err error) { +func readFull(ctx context.Context, fs *TorrentFS, t torrent.Download, off int64, p []byte) (n int, err error) { for len(p) != 0 { var nn int nn, err = blockingRead(ctx, fs, t, off, p) @@ -225,7 +225,7 @@ func (me rootNode) Lookup(ctx context.Context, name string) (_node fusefs.Node, err error) { for _, t := range me.fs.Client.Torrents() { info := t.Info() - if t.Name() != name || info == nil { + if t.Info().Name != name || info == nil { continue } __node := node{