diff --git a/database/boltdb.go b/database/boltdb.go index b493210..eec5bfe 100644 --- a/database/boltdb.go +++ b/database/boltdb.go @@ -90,8 +90,9 @@ func (b *BoltDBStorage) PutRoute(ctx context.Context, domain, creator string) (R if err != nil { return Route{}, err } + defer b.db.Commit() - return r, nil + return r, err } // DeleteRoute removes a route from the database. @@ -101,6 +102,7 @@ func (b *BoltDBStorage) DeleteRoute(ctx context.Context, id string) error { if err != nil { return err } + defer b.db.Commit() return b.db.DeleteStruct(&r) } @@ -152,6 +154,7 @@ func (b *BoltDBStorage) PutToken(ctx context.Context, token, owner string, scope if err != nil { return Token{}, err } + defer b.db.Commit() return t, nil } @@ -175,6 +178,7 @@ func (b *BoltDBStorage) DeactivateToken(ctx context.Context, id string) error { if err != nil { return err } + defer b.db.Commit() t.Active = false @@ -221,6 +225,8 @@ func (b *BoltDBStorage) PutCert(ctx context.Context, key string, data []byte) er cc.Body = b.sb.Encrypt(data) } + defer b.db.Commit() + return b.db.Save(&cc) } @@ -232,9 +238,12 @@ func (b *BoltDBStorage) DeleteCert(ct context.Context, key string) error { return err } + defer b.db.Commit() + return b.db.DeleteStruct(&cc) } +// Close ... func (b *BoltDBStorage) Close() error { return b.db.Close() }