@@ -59,11 +59,13 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error {
59
59
60
60
handler := func (idx int , bean interface {}, limit int ) error {
61
61
var item SyncRequest
62
+ var repo * repo_model.Repository
62
63
if m , ok := bean .(* repo_model.Mirror ); ok {
63
64
if m .Repo == nil {
64
65
log .Error ("Disconnected mirror found: %d" , m .ID )
65
66
return nil
66
67
}
68
+ repo = m .Repo
67
69
item = SyncRequest {
68
70
Type : PullMirrorType ,
69
71
RepoID : m .RepoID ,
@@ -73,6 +75,7 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error {
73
75
log .Error ("Disconnected push-mirror found: %d" , m .ID )
74
76
return nil
75
77
}
78
+ repo = m .Repo
76
79
item = SyncRequest {
77
80
Type : PushMirrorType ,
78
81
RepoID : m .RepoID ,
@@ -89,17 +92,16 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error {
89
92
default :
90
93
}
91
94
92
- // Check if this request is already in the queue
93
- has , err := mirrorQueue .Has (& item )
94
- if err != nil {
95
- return err
96
- }
97
- if has {
98
- return nil
99
- }
100
-
101
95
// Push to the Queue
102
96
if err := mirrorQueue .Push (& item ); err != nil {
97
+ if err == queue .ErrAlreadyInQueue {
98
+ if item .Type == PushMirrorType {
99
+ log .Trace ("PushMirrors for %-v already queued for sync" , repo )
100
+ } else {
101
+ log .Trace ("PullMirrors for %-v already queued for sync" , repo )
102
+ }
103
+ return nil
104
+ }
103
105
return err
104
106
}
105
107
@@ -110,23 +112,29 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error {
110
112
return nil
111
113
}
112
114
115
+ pullMirrorsRequested := 0
113
116
if pullLimit != 0 {
117
+ requested = 0
114
118
if err := repo_model .MirrorsIterate (func (idx int , bean interface {}) error {
115
119
return handler (idx , bean , pullLimit )
116
120
}); err != nil && err != errLimit {
117
121
log .Error ("MirrorsIterate: %v" , err )
118
122
return err
119
123
}
124
+ pullMirrorsRequested , requested = requested , 0
120
125
}
126
+ pushMirrorsRequested := 0
121
127
if pushLimit != 0 {
128
+ requested = 0
122
129
if err := repo_model .PushMirrorsIterate (func (idx int , bean interface {}) error {
123
130
return handler (idx , bean , pushLimit )
124
131
}); err != nil && err != errLimit {
125
132
log .Error ("PushMirrorsIterate: %v" , err )
126
133
return err
127
134
}
135
+ pushMirrorsRequested , requested = requested , 0
128
136
}
129
- log .Trace ("Finished: Update" )
137
+ log .Trace ("Finished: Update: %d pull mirrors and %d push mirrors queued" , pullMirrorsRequested , pushMirrorsRequested )
130
138
return nil
131
139
}
132
140
0 commit comments