(ctx context.Context, _ repo.RepositoryWriter)
| 66 | } |
| 67 | |
| 68 | func (c *commandCacheSetParams) run(ctx context.Context, _ repo.RepositoryWriter) error { |
| 69 | opts, err := repo.GetCachingOptions(ctx, c.svc.repositoryConfigFileName()) |
| 70 | if err != nil { |
| 71 | return errors.Wrap(err, "error getting caching options") |
| 72 | } |
| 73 | |
| 74 | changed := 0 |
| 75 | |
| 76 | if v := c.directory; v != "" { |
| 77 | log(ctx).Infof("setting cache directory to %v", v) |
| 78 | opts.CacheDirectory = v |
| 79 | changed++ |
| 80 | } |
| 81 | |
| 82 | if v := c.contentCacheSizeMB; v != -1 { |
| 83 | v *= 1e6 // convert MB to bytes |
| 84 | log(ctx).Infof("changing content cache size to %v", units.BytesString(v)) |
| 85 | opts.ContentCacheSizeBytes = v |
| 86 | changed++ |
| 87 | } |
| 88 | |
| 89 | if v := c.contentCacheSizeLimitMB; v != -1 { |
| 90 | v *= 1e6 // convert MB to bytes |
| 91 | log(ctx).Infof("changing content cache size limit to %v", units.BytesString(v)) |
| 92 | opts.ContentCacheSizeLimitBytes = v |
| 93 | changed++ |
| 94 | } |
| 95 | |
| 96 | if v := c.metadataCacheSizeMB; v != -1 { |
| 97 | v *= 1e6 // convert MB to bytes |
| 98 | log(ctx).Infof("changing metadata cache size to %v", units.BytesString(v)) |
| 99 | opts.MetadataCacheSizeBytes = v |
| 100 | changed++ |
| 101 | } |
| 102 | |
| 103 | if v := c.metadataCacheSizeLimitMB; v != -1 { |
| 104 | v *= 1e6 // convert MB to bytes |
| 105 | log(ctx).Infof("changing metadata cache size limit to %v", units.BytesString(v)) |
| 106 | opts.MetadataCacheSizeLimitBytes = v |
| 107 | changed++ |
| 108 | } |
| 109 | |
| 110 | if v := c.maxListCacheDuration; v != -1 { |
| 111 | log(ctx).Infof("changing list cache duration to %v", v) |
| 112 | opts.MaxListCacheDuration = content.DurationSeconds(v.Seconds()) |
| 113 | changed++ |
| 114 | } |
| 115 | |
| 116 | if v := c.metadataMinSweepAge; v != -1 { |
| 117 | log(ctx).Infof("changing minimum metadata sweep age to %v", v) |
| 118 | opts.MinMetadataSweepAge = content.DurationSeconds(v.Seconds()) |
| 119 | changed++ |
| 120 | } |
| 121 | |
| 122 | if v := c.contentMinSweepAge; v != -1 { |
| 123 | log(ctx).Infof("changing minimum content sweep age to %v", v) |
| 124 | opts.MinContentSweepAge = content.DurationSeconds(v.Seconds()) |
| 125 | changed++ |
nothing calls this directly
no test coverage detected