MCPcopy
hub / github.com/kopia/kopia / assertDirectRepository

Function assertDirectRepository

cli/app.go:412–427  ·  view source on GitHub ↗
(act func(ctx context.Context, rep repo.DirectRepository) error)

Source from the content-addressed store, hash-verified

410}
411
412func assertDirectRepository(act func(ctx context.Context, rep repo.DirectRepository) error) func(ctx context.Context, rep repo.Repository) error {
413 return func(ctx context.Context, rep repo.Repository) error {
414 if rep == nil {
415 return act(ctx, nil)
416 }
417
418 // right now this assertion never fails,
419 // but will fail in the future when we have remote repository implementation
420 lr, ok := rep.(repo.DirectRepository)
421 if !ok {
422 return errors.New("operation supported only on direct repository")
423 }
424
425 return act(ctx, lr)
426 }
427}
428
429func (c *App) directRepositoryWriteAction(act func(ctx context.Context, rep repo.DirectRepositoryWriter) error) func(ctx *kingpin.ParseContext) error {
430 return c.repositoryAction(assertDirectRepository(func(ctx context.Context, rep repo.DirectRepository) error {

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected