Skip to content
Snippets Groups Projects
Commit 76e7c3f0 authored by Ophestra's avatar Ophestra
Browse files

easier check of tag type validity

parent 72a329a6
No related branches found
Tags v1.3.3
No related merge requests found
......@@ -21,6 +21,23 @@ const (
GenericType = "generic"
)
var (
// AllowedTagTypes represent tag type strings that are allowed.
AllowedTagTypes = []string{ArtistType, CharacterType, CopyrightType, MetaType, GenericType}
allowedTagTypesMap = map[string]bool{
ArtistType: true,
CharacterType: true,
CopyrightType: true,
MetaType: true,
GenericType: true,
}
)
// TagTypeAllowed returns whether str is an allowed tag type.
func TagTypeAllowed(str string) bool {
return allowedTagTypesMap[str]
}
// Tag represents metadata of a tag.
type Tag struct {
Type string `json:"type"`
......@@ -131,13 +148,8 @@ func (s *Store) TagType(tag, t string) {
return
}
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)
if !TagTypeAllowed(t) {
log.Warnf("Invalid tag change on tag %s, got %s, expecting %s", tag, t, AllowedTagTypes)
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