]> Sergey Matveev's repositories - btrtrc.git/commitdiff
cmd/torrentfs: Tidy
authorMatt Joiner <anacrolix@gmail.com>
Wed, 1 Apr 2015 03:32:42 +0000 (14:32 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 1 Apr 2015 03:32:42 +0000 (14:32 +1100)
cmd/torrentfs/main.go

index 03edc8570c5ba20b5dca49746de39ad534c04282..61a11c2e2b435045db5436df3acef0e080fd9bc9 100644 (file)
@@ -99,13 +99,13 @@ func main() {
        client, err := torrent.NewClient(&torrent.Config{
                DataDir:         *downloadDir,
                DisableTrackers: *disableTrackers,
-               // DownloadStrategy: torrent.NewResponsiveDownloadStrategy(*readaheadBytes),
-               ListenAddr: *listenAddr,
-               NoUpload:   true, // Ensure that uploads are responsive.
+               ListenAddr:      *listenAddr,
+               NoUpload:        true, // Ensure that downloads are responsive.
        })
        if err != nil {
                log.Fatal(err)
        }
+       // This is naturally exported via GOPPROF=http.
        http.DefaultServeMux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
                client.WriteStatus(w)
        })
@@ -129,13 +129,11 @@ func main() {
                                        }
                                }
                        case dirwatch.Removed:
-                               for _, t := range client.Torrents() {
-                                       if t.InfoHash != ev.InfoHash {
-                                               continue
-                                       }
-                                       t.Drop()
+                               T, ok := client.Torrent(ev.InfoHash)
+                               if !ok {
                                        break
                                }
+                               T.Drop()
                        }
                }
        }()