MCPcopy
hub / github.com/kopia/kopia / Open

Function Open

repo/open.go:97–137  ·  view source on GitHub ↗

Open opens a Repository specified in the configuration file.

(ctx context.Context, configFile, password string, options *Options)

Source from the content-addressed store, hash-verified

95
96// Open opens a Repository specified in the configuration file.
97func Open(ctx context.Context, configFile, password string, options *Options) (rep Repository, err error) {
98 ctx, span := tracer.Start(ctx, "OpenRepository")
99 defer span.End()
100
101 defer func() {
102 if err != nil {
103 log(ctx).Errorf("failed to open repository: %v", err)
104 }
105 }()
106
107 if options == nil {
108 options = &Options{}
109 }
110
111 if options.OnFatalError == nil {
112 options.OnFatalError = func(err error) {
113 log(ctx).Errorf("FATAL: %v", err)
114 os.Exit(1)
115 }
116 }
117
118 configFile, err = filepath.Abs(configFile)
119 if err != nil {
120 return nil, errors.Wrap(err, "error resolving config file path")
121 }
122
123 lc, err := LoadConfigFromFile(configFile)
124 if err != nil {
125 return nil, err
126 }
127
128 if lc.PermissiveCacheLoading && !lc.ReadOnly {
129 return nil, ErrCannotWriteToRepoConnectionWithPermissiveCacheLoading
130 }
131
132 if lc.APIServer != nil {
133 return openAPIServer(ctx, lc.APIServer, lc.ClientOptions, lc.Caching, password, options)
134 }
135
136 return openDirect(ctx, configFile, lc, password, options)
137}
138
139func getContentCacheOrNil(ctx context.Context, si *APIServerInfo, opt *content.CachingOptions, password string, mr *metrics.Registry, timeNow func() time.Time) (*cache.PersistentCache, error) {
140 opt = opt.CloneOrDefault()

Callers 15

openSourceRepoMethod · 0.92
populateRepositoryMethod · 0.92
openRepositoryMethod · 0.92
setupMethod · 0.92
MustReopenMethod · 0.92
MustOpenAnotherMethod · 0.92
TestTimeFuncWiringFunction · 0.92
connectAPIServerAndOpenFunction · 0.92
connectAndOpenFunction · 0.92
ConnectAndOpenAPIServerFunction · 0.92

Calls 5

LoadConfigFromFileFunction · 0.85
openAPIServerFunction · 0.85
openDirectFunction · 0.85
ErrorfMethod · 0.80
StartMethod · 0.65