|
|
@ -55,9 +55,7 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error { |
|
|
|
} |
|
|
|
} |
|
|
|
log.Trace("Doing: Update") |
|
|
|
log.Trace("Doing: Update") |
|
|
|
|
|
|
|
|
|
|
|
requested := 0 |
|
|
|
handler := func(idx int, bean interface{}) error { |
|
|
|
|
|
|
|
|
|
|
|
handler := func(idx int, bean interface{}, limit int) error { |
|
|
|
|
|
|
|
var item SyncRequest |
|
|
|
var item SyncRequest |
|
|
|
var repo *repo_model.Repository |
|
|
|
var repo *repo_model.Repository |
|
|
|
if m, ok := bean.(*repo_model.Mirror); ok { |
|
|
|
if m, ok := bean.(*repo_model.Mirror); ok { |
|
|
@ -104,35 +102,35 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error { |
|
|
|
} |
|
|
|
} |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
requested++ |
|
|
|
|
|
|
|
if limit > 0 && requested > limit { |
|
|
|
|
|
|
|
return errLimit |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pullMirrorsRequested := 0 |
|
|
|
pullMirrorsRequested := 0 |
|
|
|
if pullLimit != 0 { |
|
|
|
if pullLimit != 0 { |
|
|
|
requested = 0 |
|
|
|
if err := repo_model.MirrorsIterate(pullLimit, func(idx int, bean interface{}) error { |
|
|
|
if err := repo_model.MirrorsIterate(func(idx int, bean interface{}) error { |
|
|
|
if err := handler(idx, bean); err != nil { |
|
|
|
return handler(idx, bean, pullLimit) |
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
pullMirrorsRequested++ |
|
|
|
|
|
|
|
return nil |
|
|
|
}); err != nil && err != errLimit { |
|
|
|
}); err != nil && err != errLimit { |
|
|
|
log.Error("MirrorsIterate: %v", err) |
|
|
|
log.Error("MirrorsIterate: %v", err) |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
pullMirrorsRequested, requested = requested, 0 |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pushMirrorsRequested := 0 |
|
|
|
pushMirrorsRequested := 0 |
|
|
|
if pushLimit != 0 { |
|
|
|
if pushLimit != 0 { |
|
|
|
requested = 0 |
|
|
|
if err := repo_model.PushMirrorsIterate(pushLimit, func(idx int, bean interface{}) error { |
|
|
|
if err := repo_model.PushMirrorsIterate(func(idx int, bean interface{}) error { |
|
|
|
if err := handler(idx, bean); err != nil { |
|
|
|
return handler(idx, bean, pushLimit) |
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
pushMirrorsRequested++ |
|
|
|
|
|
|
|
return nil |
|
|
|
}); err != nil && err != errLimit { |
|
|
|
}); err != nil && err != errLimit { |
|
|
|
log.Error("PushMirrorsIterate: %v", err) |
|
|
|
log.Error("PushMirrorsIterate: %v", err) |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
pushMirrorsRequested, requested = requested, 0 |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
log.Trace("Finished: Update: %d pull mirrors and %d push mirrors queued", pullMirrorsRequested, pushMirrorsRequested) |
|
|
|
log.Trace("Finished: Update: %d pull mirrors and %d push mirrors queued", pullMirrorsRequested, pushMirrorsRequested) |
|
|
|
return nil |
|
|
|
return nil |
|
|
|