client.go | 2 +- t.go | 8 ++++++++ torrent.go | 4 ++++ diff --git a/client.go b/client.go index c12eeb7d53cca85fcbb8685af3fadf811154cbf5..bd7862abbfb50f8bc25ae112ebd5544c29e4d166 100644 --- a/client.go +++ b/client.go @@ -2183,7 +2183,7 @@ t.chunkSize = pp.Integer(spec.ChunkSize) } } 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 --- a/t.go +++ b/t.go @@ -84,3 +84,11 @@ t.cl.mu.Lock() 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 f2e473dcbb1ddc4af8f4f5fadaf43b9cfaa5698d..26335e18a51718df6de0c06b35f2f82f5ded3a3c 100644 --- a/torrent.go +++ b/torrent.go @@ -103,6 +103,10 @@ piecePrioritiesReused = expvar.NewInt("piecePrioritiesReused") 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 {