]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Expose Torrent.SetDisplayName
authorMatt Joiner <anacrolix@gmail.com>
Sat, 12 Dec 2015 03:03:04 +0000 (14:03 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sat, 12 Dec 2015 03:03:04 +0000 (14:03 +1100)
client.go
t.go
torrent.go

index c12eeb7d53cca85fcbb8685af3fadf811154cbf5..bd7862abbfb50f8bc25ae112ebd5544c29e4d166 100644 (file)
--- a/client.go
+++ b/client.go
@@ -2183,7 +2183,7 @@ func (cl *Client) AddTorrentSpec(spec *TorrentSpec) (T Torrent, new bool, err er
                }
        }
        if spec.DisplayName != "" {
-               t.displayName = spec.DisplayName
+               t.setDisplayName(spec.DisplayName)
        }
        // Try to merge in info we have on the torrent. Any err left will
        // terminate the function.
diff --git a/t.go b/t.go
index ae1e1b87a49ef6aedb50dc6807120d07c444ce88..4dfbbdc45a56125169d62103b25569b9f2d099cf 100644 (file)
--- a/t.go
+++ b/t.go
@@ -84,3 +84,11 @@ func (t Torrent) Seeding() bool {
        defer t.cl.mu.Unlock()
        return t.cl.seeding(t.torrent)
 }
+
+// Clobbers the torrent display name. The display name is used as the torrent
+// name if the metainfo is not available.
+func (t Torrent) SetDisplayName(dn string) {
+       t.cl.mu.Lock()
+       defer t.cl.mu.Unlock()
+       t.torrent.setDisplayName(dn)
+}
index f2e473dcbb1ddc4af8f4f5fadaf43b9cfaa5698d..26335e18a51718df6de0c06b35f2f82f5ded3a3c 100644 (file)
@@ -103,6 +103,10 @@ var (
        piecePrioritiesNew    = expvar.NewInt("piecePrioritiesNew")
 )
 
+func (t *torrent) setDisplayName(dn string) {
+       t.displayName = dn
+}
+
 func (t *torrent) newConnPiecePriorities() []int {
        _ret := t.connPiecePriorites.Get()
        if _ret != nil {