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