Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Harbor
Commits
5decb563
Commit
5decb563
authored
5 years ago
by
wang yan
Browse files
Options
Download
Email Patches
Plain Diff
update code per review comments
Signed-off-by:
wang yan
<
wangyan@vmware.com
>
parent
942e793f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/common/dao/project_blob.go
+9
-1
src/common/dao/project_blob.go
src/common/dao/project_blob_test.go
+2
-2
src/common/dao/project_blob_test.go
src/core/api/quota/registry/registry.go
+4
-9
src/core/api/quota/registry/registry.go
with
15 additions
and
12 deletions
+15
-12
src/common/dao/project_blob.go
+
9
-
1
View file @
5decb563
...
...
@@ -16,6 +16,7 @@ package dao
import
(
"fmt"
"strings"
"time"
"github.com/goharbor/harbor/src/common/models"
...
...
@@ -51,7 +52,14 @@ func AddBlobsToProject(projectID int64, blobs ...*models.Blob) (int64, error) {
})
}
return
GetOrmer
()
.
InsertMulti
(
len
(
projectBlobs
),
projectBlobs
)
cnt
,
err
:=
GetOrmer
()
.
InsertMulti
(
10
,
projectBlobs
)
if
err
!=
nil
{
if
strings
.
Contains
(
err
.
Error
(),
"duplicate key value violates unique constraint"
)
{
return
cnt
,
ErrDupRows
}
return
cnt
,
err
}
return
cnt
,
nil
}
// RemoveBlobsFromProject ...
...
...
This diff is collapsed.
Click to expand it.
src/common/dao/project_blob_test.go
+
2
-
2
View file @
5decb563
...
...
@@ -50,7 +50,7 @@ func TestAddBlobsToProject(t *testing.T) {
})
require
.
Nil
(
t
,
err
)
for
i
:=
0
;
i
<
8888
;
i
++
{
for
i
:=
0
;
i
<
8888
8
;
i
++
{
blob
:=
&
models
.
Blob
{
Digest
:
digest
.
FromString
(
utils
.
GenerateRandomString
())
.
String
(),
Size
:
100
,
...
...
@@ -61,7 +61,7 @@ func TestAddBlobsToProject(t *testing.T) {
}
cnt
,
err
:=
AddBlobsToProject
(
pid
,
blobs
...
)
require
.
Nil
(
t
,
err
)
require
.
Equal
(
t
,
cnt
,
int64
(
8888
))
require
.
Equal
(
t
,
cnt
,
int64
(
8888
8
))
}
func
TestHasBlobInProject
(
t
*
testing
.
T
)
{
...
...
This diff is collapsed.
Click to expand it.
src/core/api/quota/registry/registry.go
+
4
-
9
View file @
5decb563
...
...
@@ -280,15 +280,10 @@ func persistPB(projects []quota.ProjectInfo) error {
log
.
Error
(
err
)
return
err
}
for
_
,
blobOfPro
:=
range
blobsOfPro
{
_
,
err
=
dao
.
AddBlobToProject
(
blobOfPro
.
ID
,
pro
.
ProjectID
)
if
err
!=
nil
{
log
.
Error
(
err
)
if
err
==
dao
.
ErrDupRows
{
continue
}
return
err
}
_
,
err
=
dao
.
AddBlobsToProject
(
pro
.
ProjectID
,
blobsOfPro
...
)
if
err
!=
nil
{
log
.
Error
(
err
)
return
err
}
log
.
Infof
(
"[Quota-Sync]:: success to persist project&blob for project: %s, progress... [%d/%d]"
,
project
.
Name
,
i
,
total
)
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment