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

Method run

cli/command_repository_set_parameters.go:165–242  ·  view source on GitHub ↗
(ctx context.Context, rep repo.DirectRepositoryWriter)

Source from the content-addressed store, hash-verified

163}
164
165func (c *commandRepositorySetParameters) run(ctx context.Context, rep repo.DirectRepositoryWriter) error {
166 mp, err := rep.FormatManager().GetMutableParameters(ctx)
167 if err != nil {
168 return errors.Wrap(err, "mutable parameters")
169 }
170
171 blobcfg, err := rep.FormatManager().BlobCfgBlob(ctx)
172 if err != nil {
173 return errors.Wrap(err, "blob configuration")
174 }
175
176 requiredFeatures, err := rep.FormatManager().RequiredFeatures(ctx)
177 if err != nil {
178 return errors.Wrap(err, "unable to get required features")
179 }
180
181 anyChange := false
182 upgradeToEpochManager := false
183
184 if c.upgradeRepositoryFormat {
185 updateEpochParameters(&mp, &anyChange, &upgradeToEpochManager)
186 }
187
188 setSizeMBParameter(ctx, c.maxPackSizeMB, "maximum pack size", &mp.MaxPackSize, &anyChange)
189
190 // prevent downgrade of index format
191 if c.indexFormatVersion != 0 && c.indexFormatVersion != mp.IndexVersion {
192 if c.indexFormatVersion > mp.IndexVersion {
193 setIntParameter(ctx, c.indexFormatVersion, "index format version", &mp.IndexVersion, &anyChange)
194 } else {
195 return errors.New("index format version can only be upgraded")
196 }
197 }
198
199 if c.retentionMode == "none" {
200 if blobcfg.IsRetentionEnabled() {
201 // disable blob retention if already enabled
202 disableBlobRetention(ctx, &blobcfg, &anyChange)
203 }
204 } else {
205 setRetentionModeParameter(ctx, blob.RetentionMode(c.retentionMode), "storage backend blob retention mode", &blobcfg.RetentionMode, &anyChange)
206 setDurationParameter(ctx, c.retentionPeriod, "storage backend blob retention period", &blobcfg.RetentionPeriod, &anyChange)
207 }
208
209 setDurationParameter(ctx, c.epochMinDuration, "minimum epoch duration", &mp.EpochParameters.MinEpochDuration, &anyChange)
210 setDurationParameter(ctx, c.epochRefreshFrequency, "epoch refresh frequency", &mp.EpochParameters.EpochRefreshFrequency, &anyChange)
211 setDurationParameter(ctx, c.epochCleanupSafetyMargin, "epoch cleanup safety margin", &mp.EpochParameters.CleanupSafetyMargin, &anyChange)
212 setIntParameter(ctx, c.epochAdvanceOnCount, "epoch advance on count", &mp.EpochParameters.EpochAdvanceOnCountThreshold, &anyChange)
213 setSizeMBParameter(ctx, c.epochAdvanceOnSizeMB, "epoch advance on total size", &mp.EpochParameters.EpochAdvanceOnTotalSizeBytesThreshold, &anyChange)
214 setIntParameter(ctx, c.epochDeleteParallelism, "epoch delete parallelism", &mp.EpochParameters.DeleteParallelism, &anyChange)
215 setIntParameter(ctx, c.epochCheckpointFrequency, "epoch range-compaction period", &mp.EpochParameters.FullCheckpointFrequency, &anyChange)
216
217 requiredFeatures = c.addRemoveUpdateRequiredFeatures(requiredFeatures, &anyChange)
218
219 if !anyChange {
220 log(ctx).Info("no changes")
221 return nil
222 }

Callers

nothing calls this directly

Calls 15

RetentionModeTypeAlias · 0.92
GetParamsFunction · 0.92
CheckExtendRetentionFunction · 0.92
updateEpochParametersFunction · 0.85
setSizeMBParameterFunction · 0.85
setIntParameterFunction · 0.85
disableBlobRetentionFunction · 0.85
setDurationParameterFunction · 0.85
BlobCfgBlobMethod · 0.80

Tested by

no test coverage detected