@@ -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 mirror 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 MirrorID [%d]" , req .Type , req .ReferenceID )
45
49
}
46
50
}
47
51
@@ -65,8 +69,8 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error {
65
69
}
66
70
repo = m .Repo
67
71
item = SyncRequest {
68
- Type : PullMirrorType ,
69
- RepoID : m .RepoID ,
72
+ Type : PullMirrorType ,
73
+ ReferenceID : m .RepoID ,
70
74
}
71
75
} else if m , ok := bean .(* repo_model.PushMirror ); ok {
72
76
if m .Repo == nil {
@@ -75,8 +79,8 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error {
75
79
}
76
80
repo = m .Repo
77
81
item = SyncRequest {
78
- Type : PushMirrorType ,
79
- RepoID : m .RepoID ,
82
+ Type : PushMirrorType ,
83
+ ReferenceID : m .ID ,
80
84
}
81
85
} else {
82
86
log .Error ("Unknown bean: %v" , bean )
@@ -161,11 +165,12 @@ func StartToMirror(repoID int64) {
161
165
}
162
166
go func () {
163
167
err := mirrorQueue .Push (& SyncRequest {
164
- Type : PullMirrorType ,
165
- RepoID : repoID ,
168
+ Type : PullMirrorType ,
169
+ ReferenceID : repoID ,
166
170
})
167
171
if err != nil {
168
- log .Error ("Unable to push sync request for to the queue for push mirror repo[%d]: Error: %v" , repoID , err )
172
+ log .Error ("Unable to push sync request for to the queue for pull mirror repo[%d]: Error: %v" , repoID , err )
173
+ return
169
174
}
170
175
}()
171
176
}
@@ -177,8 +182,8 @@ func AddPushMirrorToQueue(mirrorID int64) {
177
182
}
178
183
go func () {
179
184
err := mirrorQueue .Push (& SyncRequest {
180
- Type : PushMirrorType ,
181
- RepoID : mirrorID ,
185
+ Type : PushMirrorType ,
186
+ ReferenceID : mirrorID ,
182
187
})
183
188
if err != nil {
184
189
log .Error ("Unable to push sync request to the queue for pull mirror repo[%d]: Error: %v" , mirrorID , err )
0 commit comments