Skip to content
Snippets Groups Projects
Commit 57ebc48e authored by Ophestra's avatar Ophestra
Browse files

rename tag constants, remove unused tag type

parent f03d0a8d
No related branches found
Tags v1.2.3
No related merge requests found
......@@ -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`)
......
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment