(ctx *cli.Context)
| 119 | } |
| 120 | |
| 121 | func 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 | |
| 156 | func openUserDB(ctx *cli.Context) (module.PlainUserDB, error) { |
| 157 | _, mod, err := getCfgBlockModule(ctx) |
no test coverage detected