From: Gleb Sinyavsky Date: Sun, 27 Dec 2015 11:59:07 +0000 (+0300) Subject: cmd utils fixed X-Git-Tag: v1.0.0~947^2~4 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=052a899f6037ee5c58d80b72a2fb7479bb22e60d;p=btrtrc.git cmd utils fixed --- diff --git a/cmd/magnet-metainfo/main.go b/cmd/magnet-metainfo/main.go index 878fc7db..d3a070c0 100644 --- a/cmd/magnet-metainfo/main.go +++ b/cmd/magnet-metainfo/main.go @@ -27,9 +27,9 @@ func main() { 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 928f11f4..f02ea8e7 100644 --- a/cmd/torrent-pick/main.go +++ b/cmd/torrent-pick/main.go @@ -134,7 +134,7 @@ func main() { 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 4adda93e..43b75b5d 100644 --- a/cmd/torrent/main.go +++ b/cmd/torrent/main.go @@ -36,7 +36,7 @@ func resolvedPeerAddrs(ss []string) (ret []torrent.Peer, err error) { 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 @@ func torrentBar(t torrent.Torrent) { } }) bar.PrependFunc(func(*uiprogress.Bar) string { - return t.Name() + return t.Info().Name }) go func() { <-t.GotInfo() @@ -69,7 +69,7 @@ func torrentBar(t torrent.Torrent) { 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 b7e6095e..6e60af07 100644 --- a/download.go +++ b/download.go @@ -22,4 +22,5 @@ type Download interface { 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 9b3f3958..b9cb3ad7 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 @@ func blockingRead(ctx context.Context, fs *TorrentFS, t torrent.Torrent, off int 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 (dn dirNode) Attr(ctx context.Context, attr *fuse.Attr) error { 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{