(ctx context.Context, _ repo.Repository)
| 31 | } |
| 32 | |
| 33 | func (c *commandCacheInfo) run(ctx context.Context, _ repo.Repository) error { |
| 34 | opts, err := repo.GetCachingOptions(ctx, c.svc.repositoryConfigFileName()) |
| 35 | if err != nil { |
| 36 | return errors.Wrap(err, "error getting cache options") |
| 37 | } |
| 38 | |
| 39 | if c.onlyShowPath { |
| 40 | c.out.printStdout("%v\n", opts.CacheDirectory) |
| 41 | return nil |
| 42 | } |
| 43 | |
| 44 | entries, err := os.ReadDir(opts.CacheDirectory) |
| 45 | if err != nil { |
| 46 | return errors.Wrap(err, "unable to scan cache directory") |
| 47 | } |
| 48 | |
| 49 | path2SoftLimit := map[string]int64{ |
| 50 | "contents": opts.ContentCacheSizeBytes, |
| 51 | "metadata": opts.MetadataCacheSizeBytes, |
| 52 | "server-contents": opts.ContentCacheSizeBytes, |
| 53 | } |
| 54 | |
| 55 | path2HardLimit := map[string]int64{ |
| 56 | "contents": opts.ContentCacheSizeLimitBytes, |
| 57 | "metadata": opts.MetadataCacheSizeLimitBytes, |
| 58 | "server-contents": opts.ContentCacheSizeLimitBytes, |
| 59 | } |
| 60 | |
| 61 | path2SweepAgeSeconds := map[string]time.Duration{ |
| 62 | "contents": opts.MinContentSweepAge.DurationOrDefault(content.DefaultDataCacheSweepAge), |
| 63 | "metadata": opts.MinMetadataSweepAge.DurationOrDefault(content.DefaultMetadataCacheSweepAge), |
| 64 | "indexes": opts.MinIndexSweepAge.DurationOrDefault(content.DefaultIndexCacheSweepAge), |
| 65 | "server-contents": opts.MinContentSweepAge.DurationOrDefault(content.DefaultDataCacheSweepAge), |
| 66 | } |
| 67 | |
| 68 | for _, ent := range entries { |
| 69 | if !ent.IsDir() { |
| 70 | continue |
| 71 | } |
| 72 | |
| 73 | subdir := filepath.Join(opts.CacheDirectory, ent.Name()) |
| 74 | |
| 75 | fileCount, totalFileSize, err := scanCacheDir(subdir) |
| 76 | if err != nil { |
| 77 | return err |
| 78 | } |
| 79 | |
| 80 | maybeLimit := "" |
| 81 | |
| 82 | if l, ok := path2SoftLimit[ent.Name()]; ok { |
| 83 | var hardLimit string |
| 84 | |
| 85 | if hl := path2HardLimit[ent.Name()]; hl > 0 { |
| 86 | hardLimit = units.BytesString(hl) |
| 87 | } else { |
| 88 | hardLimit = "none" |
| 89 | } |
| 90 |
nothing calls this directly
no test coverage detected