mirror of
https://github.com/portainer/portainer.git
synced 2025-07-29 10:19:41 +02:00
fix(api): increment stack identifier atomically (#3290)
This commit is contained in:
parent
accca0f2a6
commit
53942b741a
1 changed files with 5 additions and 3 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue