all: Handle errors opening db/creating file-set (ref #5907) (#7150)

This commit is contained in:
Simon Frei
2020-12-21 12:59:22 +01:00
committed by GitHub
parent b5de49917c
commit 78bd0341a8
25 changed files with 542 additions and 396 deletions
+7 -3
View File
@@ -80,17 +80,21 @@ type App struct {
stopped chan struct{}
}
func New(cfg config.Wrapper, dbBackend backend.Backend, evLogger events.Logger, cert tls.Certificate, opts Options) *App {
func New(cfg config.Wrapper, dbBackend backend.Backend, evLogger events.Logger, cert tls.Certificate, opts Options) (*App, error) {
ll, err := db.NewLowlevel(dbBackend, evLogger, db.WithRecheckInterval(opts.DBRecheckInterval), db.WithIndirectGCInterval(opts.DBIndirectGCInterval))
if err != nil {
return nil, err
}
a := &App{
cfg: cfg,
ll: db.NewLowlevel(dbBackend, db.WithRecheckInterval(opts.DBRecheckInterval), db.WithIndirectGCInterval(opts.DBIndirectGCInterval)),
ll: ll,
evLogger: evLogger,
opts: opts,
cert: cert,
stopped: make(chan struct{}),
}
close(a.stopped) // Hasn't been started, so shouldn't block on Wait.
return a
return a, nil
}
// Start executes the app and returns once all the startup operations are done,
+4 -1
View File
@@ -80,7 +80,10 @@ func TestStartupFail(t *testing.T) {
defer os.Remove(cfg.ConfigPath())
db := backend.OpenMemory()
app := New(cfg, db, events.NoopLogger, cert, Options{})
app, err := New(cfg, db, events.NoopLogger, cert, Options{})
if err != nil {
t.Fatal(err)
}
startErr := app.Start()
if startErr == nil {
t.Fatal("Expected an error from Start, got nil")