registry: Use Batch() for all methods #141
1 changed files with 2 additions and 2 deletions
|
@ -75,7 +75,7 @@ func (o *ObjRegistry) AddObject(cid, oid, s3Bucket, s3Key, payloadHash string) e
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ObjRegistry) SetObjectStatus(id uint64, oldStatus, newStatus string) error {
|
func (o *ObjRegistry) SetObjectStatus(id uint64, oldStatus, newStatus string) error {
|
||||||
return o.boltDB.Update(func(tx *bbolt.Tx) error {
|
return o.boltDB.Batch(func(tx *bbolt.Tx) error {
|
||||||
oldB := tx.Bucket([]byte(oldStatus))
|
oldB := tx.Bucket([]byte(oldStatus))
|
||||||
if oldB == nil {
|
if oldB == nil {
|
||||||
return fmt.Errorf("bucket doesn't exist: '%s'", oldStatus)
|
return fmt.Errorf("bucket doesn't exist: '%s'", oldStatus)
|
||||||
|
@ -110,7 +110,7 @@ func (o *ObjRegistry) SetObjectStatus(id uint64, oldStatus, newStatus string) er
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ObjRegistry) DeleteObject(id uint64) error {
|
func (o *ObjRegistry) DeleteObject(id uint64) error {
|
||||||
return o.boltDB.Update(func(tx *bbolt.Tx) error {
|
return o.boltDB.Batch(func(tx *bbolt.Tx) error {
|
||||||
return tx.ForEach(func(_ []byte, b *bbolt.Bucket) error {
|
return tx.ForEach(func(_ []byte, b *bbolt.Bucket) error {
|
||||||
return b.Delete(encodeId(id))
|
return b.Delete(encodeId(id))
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue