(ctx context.Context, rep repo.DirectRepositoryWriter)
| 22 | } |
| 23 | |
| 24 | func (c *commandCacheSync) run(ctx context.Context, rep repo.DirectRepositoryWriter) error { |
| 25 | eg, ctx := errgroup.WithContext(ctx) |
| 26 | |
| 27 | ch := make(chan blob.ID, c.parallel) |
| 28 | |
| 29 | // workers that will prefetch blobs. |
| 30 | for range c.parallel { |
| 31 | eg.Go(func() error { |
| 32 | for blobID := range ch { |
| 33 | if err := rep.ContentManager().MetadataCache().PrefetchBlob(ctx, blobID); err != nil { |
| 34 | return errors.Wrap(err, "error prefetching blob") |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | return nil |
| 39 | }) |
| 40 | } |
| 41 | |
| 42 | // populate channel with blob IDs. |
| 43 | eg.Go(func() error { |
| 44 | defer close(ch) |
| 45 | |
| 46 | return rep.BlobReader().ListBlobs(ctx, content.PackBlobIDPrefixSpecial, func(bm blob.Metadata) error { |
| 47 | ch <- bm.BlobID |
| 48 | |
| 49 | return nil |
| 50 | }) |
| 51 | }) |
| 52 | |
| 53 | return errors.Wrap(eg.Wait(), "error synchronizing metadata cache") |
| 54 | } |
nothing calls this directly
no test coverage detected