mirror of https://github.com/portainer/portainer
fix(api): increment stack identifier atomically (#3290)
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 {
|
func GetNextIdentifier(db *bolt.DB, bucketName string) int {
|
||||||
var identifier int
|
var identifier int
|
||||||
|
|
||||||
db.View(func(tx *bolt.Tx) error {
|
db.Update(func(tx *bolt.Tx) error {
|
||||||
bucket := tx.Bucket([]byte(bucketName))
|
bucket := tx.Bucket([]byte(bucketName))
|
||||||
id := bucket.Sequence()
|
id, err := bucket.NextSequence()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
identifier = int(id)
|
identifier = int(id)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
identifier++
|
|
||||||
return identifier
|
return identifier
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue