MCPcopy Index your code
hub / github.com/foxcpp/maddy / openStorage

Function openStorage

internal/cli/ctl/moduleinit.go:121–154  ·  view source on GitHub ↗
(ctx *cli.Context)

Source from the content-addressed store, hash-verified

119}
120
121func openStorage(ctx *cli.Context) (module.Storage, error) {
122 _, mod, err := getCfgBlockModule(ctx)
123 if err != nil {
124 return nil, err
125 }
126
127 storage, ok := mod.(module.Storage)
128 if !ok {
129 return nil, cli.Exit(fmt.Sprintf("Error: configuration block %s is not an IMAP storage", ctx.String("cfg-block")), 2)
130 }
131
132 started := false
133 if lt, ok := storage.(container.LifetimeModule); ok {
134 if err := lt.Start(); err != nil {
135 return nil, err
136 }
137 started = true
138 }
139
140 if updStore, ok := mod.(updatepipe.Backend); ok {
141 if err := updStore.EnableUpdatePipe(updatepipe.ModePush); err != nil && !errors.Is(err, os.ErrNotExist) {
142 fmt.Fprintf(os.Stderr, "Failed to initialize update pipe, do not remove messages from mailboxes open by clients: %v\n", err)
143 }
144 } else {
145 fmt.Fprintf(os.Stderr, "No update pipe support, do not remove messages from mailboxes open by clients\n")
146 }
147
148 if started {
149 if ms, ok := storage.(module.ManageableStorage); ok {
150 return &managedStorage{ManageableStorage: ms, started: started}, nil
151 }
152 }
153 return storage, nil
154}
155
156func openUserDB(ctx *cli.Context) (module.PlainUserDB, error) {
157 _, mod, err := getCfgBlockModule(ctx)

Callers 2

initFunction · 0.85
initFunction · 0.85

Calls 4

getCfgBlockModuleFunction · 0.85
StartMethod · 0.65
EnableUpdatePipeMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected