(ctx context.Context, rep repo.Repository)
| 27 | } |
| 28 | |
| 29 | func (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 | |
| 52 | func clearCacheDirectory(ctx context.Context, d string) error { |
| 53 | log(ctx).Infof("Clearing cache directory: %v.", d) |
nothing calls this directly
no test coverage detected