Skip to content

Commit 88dcb4c

Browse files
committed
exit status check and make sure loops return
the create command doesn't exit properly after a snapshot completes
1 parent 55bb87d commit 88dcb4c

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

cmd/filecoin-chain-archiver/cmds/create.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ var cmdCreate = &cli.Command{
368368

369369
logger.Debugw("lock aquired", "expiry", lock.Expiry())
370370
}
371+
break
371372
}
372373
}()
373374

@@ -400,6 +401,9 @@ var cmdCreate = &cli.Command{
400401
if size == 0 {
401402
continue
402403
}
404+
if size == lastSize {
405+
break
406+
}
403407
logger.Infow("update", "total", size, "speed", (size-lastSize)/int64(flagProgressUpdate/time.Second))
404408
lastSize = size
405409
case err := <-errCh:
@@ -408,21 +412,12 @@ var cmdCreate = &cli.Command{
408412
}
409413
}
410414
}
415+
return
411416
}()
412417

413418
if flagDiscard {
414419
logger.Infow("discarding output")
415-
g, ctxGroup := errgroup.WithContext(ctx)
416-
g.Go(func() error {
417-
return runWriteCompressed(ctxGroup, rrPath+".zstd", rr)
418-
})
419-
if err := g.Wait(); err != nil {
420-
return err
421-
}
422-
423-
if err := <-errCh; err != nil {
424-
return err
425-
}
420+
return runWriteCompressed(rrPath+".zstd", rr)
426421
} else {
427422
host := u.Hostname()
428423
port := u.Port()
@@ -514,7 +509,7 @@ func compress(source io.Reader) io.Reader {
514509
return r
515510
}
516511

517-
func runWriteCompressed(ctx context.Context, path string, source io.Reader) error {
512+
func runWriteCompressed(path string, source io.Reader) error {
518513
file, err := os.Create(path)
519514
if err != nil {
520515
return err

0 commit comments

Comments
 (0)