MCPcopy
hub / github.com/kopia/kopia / run

Method run

cli/command_cache_sync.go:24–54  ·  view source on GitHub ↗
(ctx context.Context, rep repo.DirectRepositoryWriter)

Source from the content-addressed store, hash-verified

22}
23
24func (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}

Callers

nothing calls this directly

Calls 6

MetadataCacheMethod · 0.80
PrefetchBlobMethod · 0.65
ContentManagerMethod · 0.65
ListBlobsMethod · 0.65
BlobReaderMethod · 0.65
WaitMethod · 0.65

Tested by

no test coverage detected