Skip to content
Snippets Groups Projects
Commit 1b1147e4 authored by Ophestra's avatar Ophestra
Browse files

move locking of tag after fetching tag info

parent 5959868f
Branches
Tags v1.2.5
No related merge requests found
......@@ -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))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment