From: Matt Joiner Date: Sat, 12 Dec 2015 03:03:04 +0000 (+1100) Subject: Expose Torrent.SetDisplayName X-Git-Tag: v1.0.0~968 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=86c4c609f10d72d0833323f62b8caed217a4dda1;p=btrtrc.git Expose Torrent.SetDisplayName --- diff --git a/client.go b/client.go index c12eeb7d..bd7862ab 100644 --- 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 ae1e1b87..4dfbbdc4 100644 --- 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) +} diff --git a/torrent.go b/torrent.go index f2e473dc..26335e18 100644 --- a/torrent.go +++ b/torrent.go @@ -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 {