|
@@ -128,6 +128,14 @@ func (r *Repo) Notify() {
|
128
|
128
|
}
|
129
|
129
|
}
|
130
|
130
|
|
|
131
|
+// refreshed indicates that the repo has successfully fetched from upstream.
|
|
132
|
+func (r *Repo) refreshed() {
|
|
133
|
+ select {
|
|
134
|
+ case r.C <- struct{}{}:
|
|
135
|
+ default:
|
|
136
|
+ }
|
|
137
|
+}
|
|
138
|
+
|
131
|
139
|
// errorIfNotReady returns the appropriate error if the repo is not
|
132
|
140
|
// ready, and `nil` otherwise.
|
133
|
141
|
func (r *Repo) errorIfNotReady() error {
|
|
@@ -222,6 +230,9 @@ func (r *Repo) Start(shutdown <-chan struct{}, done *sync.WaitGroup) error {
|
222
|
230
|
cancel()
|
223
|
231
|
if err == nil {
|
224
|
232
|
r.setStatus(RepoReady, nil)
|
|
233
|
+ // Treat every transition to ready as a refresh, so
|
|
234
|
+ // that any listeners can respond in the same way.
|
|
235
|
+ r.refreshed()
|
225
|
236
|
continue // with new status, skipping timer
|
226
|
237
|
}
|
227
|
238
|
r.setStatus(RepoCloned, err)
|
|
@@ -257,10 +268,7 @@ func (r *Repo) Refresh(ctx context.Context) error {
|
257
|
268
|
if err := r.fetch(ctx); err != nil {
|
258
|
269
|
return err
|
259
|
270
|
}
|
260
|
|
- select {
|
261
|
|
- case r.C <- struct{}{}:
|
262
|
|
- default:
|
263
|
|
- }
|
|
271
|
+ r.refreshed()
|
264
|
272
|
return nil
|
265
|
273
|
}
|
266
|
274
|
|