MCPcopy
hub / github.com/kopia/kopia / clearCacheDirectory

Function clearCacheDirectory

cli/command_cache_clear.go:52–67  ·  view source on GitHub ↗
(ctx context.Context, d string)

Source from the content-addressed store, hash-verified

50}
51
52func clearCacheDirectory(ctx context.Context, d string) error {
53 log(ctx).Infof("Clearing cache directory: %v.", d)
54
55 err := retry.WithExponentialBackoffNoValue(ctx, "delete cache", func() error {
56 return os.RemoveAll(d)
57 }, retry.Always)
58 if err != nil {
59 return errors.Wrap(err, "error removing cache directory")
60 }
61
62 if err := os.MkdirAll(d, cache.DirMode); err != nil {
63 return errors.Wrap(err, "error creating cache directory")
64 }
65
66 return nil
67}

Callers 1

runMethod · 0.85

Calls 3

MkdirAllMethod · 0.65
RemoveAllMethod · 0.45

Tested by

no test coverage detected