Skip to content

Commit

Permalink
respect the contexts a little better (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping authored Oct 4, 2023
2 parents 29ee1ce + a2b5d72 commit 8a63a7a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bgs/bgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,15 @@ func (bgs *BGS) runRepoCompaction(ctx context.Context, lim int, dry bool) (*comp

results := make(map[models.Uid]*carstore.CompactionStats)
for _, r := range repos {
select {
case <-ctx.Done():
return &compactionStats{
Targets: repos,
Completed: results,
}, nil
default:
}

st, err := bgs.repoman.CarStore().CompactUserShards(context.Background(), r.Usr)
if err != nil {
log.Errorf("failed to compact shards for user %d: %s", r.Usr, err)
Expand Down

0 comments on commit 8a63a7a

Please sign in to comment.