Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
image board
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
random asynchronous nightmare distributor
image board
Commits
57ebc48e
Commit
57ebc48e
authored
3 years ago
by
Ophestra
Browse files
Options
Downloads
Patches
Plain Diff
rename tag constants, remove unused tag type
parent
f03d0a8d
No related branches found
Branches containing commit
Tags
v1.2.3
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
store/misc.go
+0
-15
0 additions, 15 deletions
store/misc.go
store/tag.go
+21
-9
21 additions, 9 deletions
store/tag.go
with
21 additions
and
24 deletions
store/misc.go
+
0
−
15
View file @
57ebc48e
...
...
@@ -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`
)
...
...
This diff is collapsed.
Click to expand it.
store/tag.go
+
21
−
9
View file @
57ebc48e
...
...
@@ -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
:
Generic
Type
,
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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment