From 86c4c609f10d72d0833323f62b8caed217a4dda1 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sat, 12 Dec 2015 14:03:04 +1100 Subject: [PATCH] Expose Torrent.SetDisplayName --- client.go | 2 +- t.go | 8 ++++++++ torrent.go | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) 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 { -- 2.48.1