summaryrefslogtreecommitdiff
path: root/store/tag.go
diff options
context:
space:
mode:
Diffstat (limited to 'store/tag.go')
-rw-r--r--store/tag.go30
1 files changed, 21 insertions, 9 deletions
diff --git a/store/tag.go b/store/tag.go
index dc9073f..580cd12 100644
--- a/store/tag.go
+++ b/store/tag.go
@@ -8,6 +8,19 @@ import (
"time"
)
+const (
+ // ArtistType is the tag type artist.
+ ArtistType = "artist"
+ // CharacterType is the tag type character.
+ CharacterType = "character"
+ // CopyrightType is the tag type copyright.
+ CopyrightType = "copyright"
+ // MetaType is the tag type meta.
+ MetaType = "meta"
+ // GenericType is the tag type generic.
+ GenericType = "generic"
+)
+
// Tag represents metadata of a tag.
type Tag struct {
Type string `json:"type"`
@@ -59,7 +72,7 @@ func (s *Store) TagCreate(tag string) bool {
if err := os.Mkdir(s.TagPath(tag), s.PermissionDir); err != nil {
s.fatalClose(fmt.Sprintf("Error creating tag %s, %s", tag, err))
}
- if payload, err := json.Marshal(Tag{Type: Generic, CreationTime: time.Now().UTC()}); err != nil {
+ if payload, err := json.Marshal(Tag{Type: GenericType, CreationTime: time.Now().UTC()}); err != nil {
s.fatalClose(fmt.Sprintf("Error generating tag %s metadata, %s", tag, err))
} else {
if err = os.WriteFile(s.TagMetadataPath(tag), payload, s.PermissionFile); err != nil {
@@ -121,14 +134,13 @@ func (s *Store) TagType(tag, t string) {
s.getLock("tag_" + tag).Lock()
defer s.getLock("tag_" + tag).Unlock()
- if t != Artist &&
- t != Character &&
- t != Copyright &&
- t != Generic &&
- t != Group &&
- t != Meta {
- log.Warnf("Invalid tag change on tag %s, got %s, expecting {%s,%s,%s,%s,%s,%s}", tag, t,
- Artist, Character, Copyright, Generic, Group, Meta)
+ if t != ArtistType &&
+ t != CharacterType &&
+ t != CopyrightType &&
+ t != GenericType &&
+ t != MetaType {
+ log.Warnf("Invalid tag change on tag %s, got %s, expecting {%s,%s,%s,%s,%s}", tag, t,
+ ArtistType, CharacterType, CopyrightType, GenericType, MetaType)
return
}
info := s.TagInfo(tag)