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
GitLab 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
72e13105
Commit
72e13105
authored
Sep 9, 2021
by
Ophestra
Browse files
Options
Downloads
Patches
Plain Diff
record child for grouped images, correct logging in ImageUpdate
parent
b2991228
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
store/image.go
+41
-6
41 additions, 6 deletions
store/image.go
with
41 additions
and
6 deletions
store/image.go
+
41
−
6
View file @
72e13105
...
@@ -24,6 +24,7 @@ type Image struct {
...
@@ -24,6 +24,7 @@ type Image struct {
User
string
`json:"user"`
User
string
`json:"user"`
Source
string
`json:"source"`
Source
string
`json:"source"`
Parent
string
`json:"parent"`
Parent
string
`json:"parent"`
Child
string
`json:"child"`
Commentary
string
`json:"commentary"`
Commentary
string
`json:"commentary"`
CommentaryTranslation
string
`json:"commentary_translation"`
CommentaryTranslation
string
`json:"commentary_translation"`
}
}
...
@@ -302,27 +303,61 @@ func (s *Store) ImageUpdate(hash, source, parent, commentary, commentaryTranslat
...
@@ -302,27 +303,61 @@ func (s *Store) ImageUpdate(hash, source, parent, commentary, commentaryTranslat
s
.
getLock
(
hash
)
.
Lock
()
s
.
getLock
(
hash
)
.
Lock
()
defer
s
.
getLock
(
hash
)
.
Unlock
()
defer
s
.
getLock
(
hash
)
.
Unlock
()
var
msg
string
// Update and save
// Update and save
if
source
!=
"
\0
00"
{
if
source
!=
"
\0
00"
{
info
.
Source
=
source
info
.
Source
=
source
msg
+=
"source"
}
}
if
parent
!=
"
\0
00"
&&
s
.
ImageSnowflake
(
parent
)
.
Snowflake
==
parent
{
if
parent
!=
"
\0
00"
{
if
p
:=
s
.
ImageSnowflake
(
parent
);
p
.
Snowflake
==
parent
{
s
.
getLock
(
p
.
Hash
)
.
Lock
()
defer
s
.
getLock
(
p
.
Hash
)
.
Unlock
()
info
.
Parent
=
parent
info
.
Parent
=
parent
// Update the parent to reflect the child
p
.
Child
=
info
.
Snowflake
s
.
imageMetadataWrite
(
p
)
if
msg
!=
""
{
msg
+=
", "
}
msg
+=
"parent "
+
parent
}
}
}
if
commentary
!=
"
\0
00"
{
if
commentary
!=
"
\0
00"
{
info
.
Commentary
=
commentary
info
.
Commentary
=
commentary
if
msg
!=
""
{
msg
+=
", "
}
msg
+=
"commentary"
}
}
if
commentaryTranslation
!=
"
\0
00"
{
if
commentaryTranslation
!=
"
\0
00"
{
info
.
CommentaryTranslation
=
commentaryTranslation
info
.
CommentaryTranslation
=
commentaryTranslation
if
msg
!=
""
{
msg
+=
", "
}
}
msg
+=
"commentary translation"
}
if
msg
!=
""
{
s
.
imageMetadataWrite
(
info
)
log
.
Infof
(
"Image %s %s updated."
,
info
.
Snowflake
,
msg
)
}
}
func
(
s
*
Store
)
imageMetadataWrite
(
info
Image
)
{
if
payload
,
err
:=
json
.
Marshal
(
info
);
err
!=
nil
{
if
payload
,
err
:=
json
.
Marshal
(
info
);
err
!=
nil
{
s
.
fatalClose
(
fmt
.
Sprintf
(
"Error encoding metadata of image %s
while updating
, %s"
,
h
ash
,
err
))
s
.
fatalClose
(
fmt
.
Sprintf
(
"Error encoding metadata of image %s, %s"
,
info
.
H
ash
,
err
))
}
else
{
}
else
{
if
err
=
os
.
WriteFile
(
s
.
ImageMetadataPath
(
h
ash
),
payload
,
s
.
PermissionFile
);
err
!=
nil
{
if
err
=
os
.
WriteFile
(
s
.
ImageMetadataPath
(
info
.
H
ash
),
payload
,
s
.
PermissionFile
);
err
!=
nil
{
s
.
fatalClose
(
fmt
.
Sprintf
(
"Error saving metadata of image %s
while updating
, %s"
,
h
ash
,
err
))
s
.
fatalClose
(
fmt
.
Sprintf
(
"Error saving metadata of image %s, %s"
,
info
.
H
ash
,
err
))
}
}
}
}
log
.
Infof
(
"Image hash %s source set to %s."
,
hash
,
source
)
}
}
// ImageSnowflakes returns a slice of image snowflakes.
// ImageSnowflakes returns a slice of image snowflakes.
...
...
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