MCPcopy
hub / github.com/kopia/kopia / openRepository

Method openRepository

cli/config.go:42–64  ·  view source on GitHub ↗
(ctx context.Context, required bool)

Source from the content-addressed store, hash-verified

40}
41
42func (c *App) openRepository(ctx context.Context, required bool) (repo.Repository, error) {
43 if _, err := os.Stat(c.repositoryConfigFileName()); os.IsNotExist(err) {
44 if !required {
45 return nil, nil
46 }
47
48 return nil, errors.New("repository is not connected. See https://kopia.io/docs/repositories/")
49 }
50
51 c.maybePrintUpdateNotification(ctx)
52
53 pass, err := c.getPasswordFromFlags(ctx, false, true)
54 if err != nil {
55 return nil, errors.Wrap(err, "get password")
56 }
57
58 r, err := repo.Open(ctx, c.repositoryConfigFileName(), pass, c.optionsFromFlags(ctx))
59 if os.IsNotExist(err) {
60 return nil, errors.New("not connected to a repository, use 'kopia connect'")
61 }
62
63 return r, errors.Wrap(err, "unable to open repository")
64}
65
66func (c *App) optionsFromFlags(ctx context.Context) *repo.Options {
67 return &repo.Options{

Callers 2

repositoryActionMethod · 0.95
repositoryHintActionMethod · 0.95

Calls 7

getPasswordFromFlagsMethod · 0.95
optionsFromFlagsMethod · 0.95
OpenFunction · 0.92
StatMethod · 0.65
IsNotExistMethod · 0.65

Tested by

no test coverage detected