Expose Torrent.SetDisplayName

This commit is contained in:
Matt Joiner 2015-12-12 14:03:04 +11:00
parent 83045db3e5
commit 86c4c609f1
3 changed files with 13 additions and 1 deletions

View File

@ -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.

8
t.go
View File

@ -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)
}

View 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 {