cmd/torrentfs/main.go | 14 ++++++-------- diff --git a/cmd/torrentfs/main.go b/cmd/torrentfs/main.go index 03edc8570c5ba20b5dca49746de39ad534c04282..61a11c2e2b435045db5436df3acef0e080fd9bc9 100644 --- a/cmd/torrentfs/main.go +++ b/cmd/torrentfs/main.go @@ -99,13 +99,13 @@ defer conn.Close() 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 @@ log.Printf("error adding magnet: %s", err) } } 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() } } }()