summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandomChars <random@chars.jp>2021-09-23 12:55:50 +0900
committerRandomChars <random@chars.jp>2021-09-23 12:55:50 +0900
commit1b1147e422aaa83c33e542c58c7649ceef18b030 (patch)
tree2aa35f6e98397aea67d0a291c104b66c99e79711
parent5959868fa3535e2617fc713dca27fe9cae8c6653 (diff)
move locking of tag after fetching tag infov1.2.5
-rw-r--r--store/tag.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/store/tag.go b/store/tag.go
index 580cd12..1e92630 100644
--- a/store/tag.go
+++ b/store/tag.go
@@ -125,15 +125,12 @@ func (s *Store) TagInfo(tag string) Tag {
return Tag{}
}
-// TagType sets type of a tag.
+// TagType sets type of tag.
func (s *Store) TagType(tag, t string) {
if !nameRegex.MatchString(tag) || !s.file(s.TagMetadataPath(tag)) {
return
}
- s.getLock("tag_" + tag).Lock()
- defer s.getLock("tag_" + tag).Unlock()
-
if t != ArtistType &&
t != CharacterType &&
t != CopyrightType &&
@@ -144,6 +141,10 @@ func (s *Store) TagType(tag, t string) {
return
}
info := s.TagInfo(tag)
+
+ s.getLock("tag_" + tag).Lock()
+ defer s.getLock("tag_" + tag).Unlock()
+
info.Type = t
if payload, err := json.Marshal(info); err != nil {
s.fatalClose(fmt.Sprintf("Error updating tag %s metadata, %s", tag, err))