database: commit

This commit is contained in:
Cadey Ratio 2017-04-28 22:58:08 -07:00
parent 08d78cf461
commit 376f5d4d3d
1 changed files with 10 additions and 1 deletions

View File

@ -90,8 +90,9 @@ func (b *BoltDBStorage) PutRoute(ctx context.Context, domain, creator string) (R
if err != nil { if err != nil {
return Route{}, err return Route{}, err
} }
defer b.db.Commit()
return r, nil return r, err
} }
// DeleteRoute removes a route from the database. // DeleteRoute removes a route from the database.
@ -101,6 +102,7 @@ func (b *BoltDBStorage) DeleteRoute(ctx context.Context, id string) error {
if err != nil { if err != nil {
return err return err
} }
defer b.db.Commit()
return b.db.DeleteStruct(&r) return b.db.DeleteStruct(&r)
} }
@ -152,6 +154,7 @@ func (b *BoltDBStorage) PutToken(ctx context.Context, token, owner string, scope
if err != nil { if err != nil {
return Token{}, err return Token{}, err
} }
defer b.db.Commit()
return t, nil return t, nil
} }
@ -175,6 +178,7 @@ func (b *BoltDBStorage) DeactivateToken(ctx context.Context, id string) error {
if err != nil { if err != nil {
return err return err
} }
defer b.db.Commit()
t.Active = false 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) cc.Body = b.sb.Encrypt(data)
} }
defer b.db.Commit()
return b.db.Save(&cc) return b.db.Save(&cc)
} }
@ -232,9 +238,12 @@ func (b *BoltDBStorage) DeleteCert(ct context.Context, key string) error {
return err return err
} }
defer b.db.Commit()
return b.db.DeleteStruct(&cc) return b.db.DeleteStruct(&cc)
} }
// Close ...
func (b *BoltDBStorage) Close() error { func (b *BoltDBStorage) Close() error {
return b.db.Close() return b.db.Close()
} }