]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Inlineable `(*Torrent).SetDisplayName()` (#625)
authorYenForYang <YenForYang@users.noreply.github.com>
Wed, 15 Sep 2021 00:27:52 +0000 (19:27 -0500)
committerGitHub <noreply@github.com>
Wed, 15 Sep 2021 00:27:52 +0000 (10:27 +1000)
t.go

diff --git a/t.go b/t.go
index 02d629794a333642568a8f96130ebcd032e17cba..5fa9f3ddc22921e1b5ba1352b4040d16f719cf6a 100644 (file)
--- a/t.go
+++ b/t.go
@@ -130,15 +130,14 @@ func (t *Torrent) Seeding() bool {
        return t.seeding()
 }
 
-// Clobbers the torrent display name. The display name is used as the torrent
-// name if the metainfo is not available.
+// Clobbers the torrent display name if metainfo is unavailable.
+// The display name is used as the torrent name while the metainfo is unavailable.
 func (t *Torrent) SetDisplayName(dn string) {
        t.nameMu.Lock()
-       defer t.nameMu.Unlock()
-       if t.haveInfo() {
-               return
+       if !t.haveInfo() {
+               t.displayName = dn
        }
-       t.displayName = dn
+       t.nameMu.Unlock()
 }
 
 // The current working name for the torrent. Either the name in the info dict,