]> Sergey Matveev's repositories - btrtrc.git/commitdiff
cmd utils fixed
authorGleb Sinyavsky <zhulik.gleb@gmail.com>
Sun, 27 Dec 2015 11:59:07 +0000 (14:59 +0300)
committerGleb Sinyavsky <zhulik.gleb@gmail.com>
Sun, 27 Dec 2015 11:59:07 +0000 (14:59 +0300)
cmd/magnet-metainfo/main.go
cmd/torrent-pick/main.go
cmd/torrent/main.go
download.go
fs/torrentfs.go

index 878fc7db9404c81445c57325b9a2ce16bde88982..d3a070c0120b5cb515d2d7a24590a005a478587f 100644 (file)
@@ -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)
                        }
index 928f11f4df00d16b0f7832c1e8ae7ac69e2ead54..f02ea8e7cc69656b9e422c9da4b28e10a8a671d1 100644 (file)
@@ -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 {
index 4adda93e07cf71678e8a8a8d6764b0bc5af20448..43b75b5dbcfe72c76838839c10d3aca3e26c1072 100644 (file)
@@ -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 {
index b7e6095eaf4031dcf2f7c8a6731ea8d0c0eacb37..6e60af07a53c9e301c105ba039398f2d048f6771 100644 (file)
@@ -22,4 +22,5 @@ type Download interface {
        AddPeers(pp []Peer) error
        DownloadAll()
        Trackers() [][]tracker.Client
+       Files() (ret []File)
 }
\ No newline at end of file
index 9b3f3958768532a1497d9befbd450a4ba2d64928..b9cb3ad70e8acacaace2930720ca612acd0deff4 100644 (file)
@@ -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{