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

Method run

cli/command_cache_clear.go:29–50  ·  view source on GitHub ↗
(ctx context.Context, rep repo.Repository)

Source from the content-addressed store, hash-verified

27}
28
29func (c *commandCacheClear) run(ctx context.Context, rep repo.Repository) error {
30 opts, err := repo.GetCachingOptions(ctx, c.svc.repositoryConfigFileName())
31 if err != nil {
32 return errors.Wrap(err, "error getting caching options")
33 }
34
35 d := opts.CacheDirectory
36 if d == "" {
37 return errors.New("caching not enabled")
38 }
39
40 // close repository before removing cache
41 if err := rep.Close(ctx); err != nil {
42 return errors.Wrap(err, "unable to close repository")
43 }
44
45 if c.partial == "" {
46 return clearCacheDirectory(ctx, d)
47 }
48
49 return clearCacheDirectory(ctx, filepath.Join(d, c.partial))
50}
51
52func clearCacheDirectory(ctx context.Context, d string) error {
53 log(ctx).Infof("Clearing cache directory: %v.", d)

Callers

nothing calls this directly

Calls 4

GetCachingOptionsFunction · 0.92
clearCacheDirectoryFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected