fix(api): increment stack identifier atomically (#3290)

pull/3796/head
Aaron Korte 5 years ago committed by Anthony Lapenna
parent accca0f2a6
commit 53942b741a

@ -82,13 +82,15 @@ func DeleteObject(db *bolt.DB, bucketName string, key []byte) error {
func GetNextIdentifier(db *bolt.DB, bucketName string) int {
var identifier int
db.View(func(tx *bolt.Tx) error {
db.Update(func(tx *bolt.Tx) error {
bucket := tx.Bucket([]byte(bucketName))
id := bucket.Sequence()
id, err := bucket.NextSequence()
if err != nil {
return err
}
identifier = int(id)
return nil
})
identifier++
return identifier
}

Loading…
Cancel
Save