summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandomChars <random@chars.jp>2021-09-11 10:19:38 +0900
committerRandomChars <random@chars.jp>2021-09-11 10:19:38 +0900
commit57ebc48e28a6688c5e07235b3ead6856575a88c9 (patch)
tree8afbc3a7d517c0f349cfbfc19043c38ad5ec391a
parentf03d0a8d3be7676fb104522a95e8d1c4c117da7f (diff)
rename tag constants, remove unused tag typev1.2.3
-rw-r--r--store/misc.go15
-rw-r--r--store/tag.go30
2 files changed, 21 insertions, 24 deletions
diff --git a/store/misc.go b/store/misc.go
index fd5f474..a137198 100644
--- a/store/misc.go
+++ b/store/misc.go
@@ -7,21 +7,6 @@ import (
const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
-const (
- // Artist is the tag type artist.
- Artist = "artist"
- // Character is the tag type character.
- Character = "character"
- // Copyright is the tag type copyright.
- Copyright = "copyright"
- // Generic is the tag type generic.
- Generic = "generic"
- // Group is the tag type group.
- Group = "group"
- // Meta is the tag type meta.
- Meta = "meta"
-)
-
var (
nameRegex = regexp.MustCompile(`^[a-z0-9()_-]{3,}$`)
sha256Regex = regexp.MustCompile(`\b[A-Fa-f0-9]{64}\b`)
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)