@@ -29,19 +29,23 @@ const (
29
29
30
30
// SyncRequest for the mirror queue
31
31
type SyncRequest struct {
32
- Type SyncType
33
- RepoID int64
32
+ Type SyncType
33
+ ReferenceID int64 // RepoID for pull mirror, MirrorID fro push mirror
34
34
}
35
35
36
36
// doMirrorSync causes this request to mirror itself
37
37
func doMirrorSync (ctx context.Context , req * SyncRequest ) {
38
+ if req .ReferenceID == 0 {
39
+ log .Warn ("Skipping mirror sync request, no reference ID was specified" )
40
+ return
41
+ }
38
42
switch req .Type {
39
43
case PushMirrorType :
40
- _ = SyncPushMirror (ctx , req .RepoID )
44
+ _ = SyncPushMirror (ctx , req .ReferenceID )
41
45
case PullMirrorType :
42
- _ = SyncPullMirror (ctx , req .RepoID )
46
+ _ = SyncPullMirror (ctx , req .ReferenceID )
43
47
default :
44
- log .Error ("Unknown Request type in queue: %v for RepoID [%d]" , req .Type , req .RepoID )
48
+ log .Error ("Unknown Request type in queue: %v for ReferenceID [%d]" , req .Type , req .ReferenceID )
45
49
}
46
50
}
47
51
@@ -67,8 +71,8 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error {
67
71
}
68
72
repo = m .Repo
69
73
item = SyncRequest {
70
- Type : PullMirrorType ,
71
- RepoID : m .RepoID ,
74
+ Type : PullMirrorType ,
75
+ ReferenceID : m .RepoID ,
72
76
}
73
77
} else if m , ok := bean .(* repo_model.PushMirror ); ok {
74
78
if m .Repo == nil {
@@ -77,8 +81,8 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error {
77
81
}
78
82
repo = m .Repo
79
83
item = SyncRequest {
80
- Type : PushMirrorType ,
81
- RepoID : m .RepoID ,
84
+ Type : PushMirrorType ,
85
+ ReferenceID : m .ID ,
82
86
}
83
87
} else {
84
88
log .Error ("Unknown bean: %v" , bean )
@@ -162,8 +166,8 @@ func StartToMirror(repoID int64) {
162
166
}
163
167
go func () {
164
168
err := mirrorQueue .Push (& SyncRequest {
165
- Type : PullMirrorType ,
166
- RepoID : repoID ,
169
+ Type : PullMirrorType ,
170
+ ReferenceID : repoID ,
167
171
})
168
172
if err != nil {
169
173
log .Error ("Unable to push sync request for to the queue for push mirror repo[%d]: Error: %v" , repoID , err )
@@ -178,8 +182,8 @@ func AddPushMirrorToQueue(mirrorID int64) {
178
182
}
179
183
go func () {
180
184
err := mirrorQueue .Push (& SyncRequest {
181
- Type : PushMirrorType ,
182
- RepoID : mirrorID ,
185
+ Type : PushMirrorType ,
186
+ ReferenceID : mirrorID ,
183
187
})
184
188
if err != nil {
185
189
log .Error ("Unable to push sync request to the queue for pull mirror repo[%d]: Error: %v" , mirrorID , err )
0 commit comments