fix context cancelling

This commit is contained in:
George Angel 2019-01-02 22:00:08 +00:00
parent db07a432cd
commit 5a2584188f
1 changed files with 2 additions and 1 deletions

View File

@ -185,7 +185,6 @@ func main() {
failCount := 0
for {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(*flSyncTimeout))
defer cancel()
err := syncRepo(ctx, *flRepo, *flBranch, *flRev, *flDepth, *flRoot, *flDest)
if err != nil {
if initialSync || failCount >= *flMaxSyncFailures {
@ -196,6 +195,7 @@ func main() {
failCount++
log.Errorf("unexpected error syncing repo: %v", err)
log.V(0).Infof("waiting %v before retrying", waitTime(*flWait))
cancel()
time.Sleep(waitTime(*flWait))
continue
}
@ -215,6 +215,7 @@ func main() {
failCount = 0
log.V(1).Infof("next sync in %v", waitTime(*flWait))
cancel()
time.Sleep(waitTime(*flWait))
}
}