From 5ddb2c3cb4608e7dd952a995d035703c50986944 Mon Sep 17 00:00:00 2001 From: vishalnayak Date: Sun, 24 Jun 2018 07:54:00 -0400 Subject: [PATCH] Add back upsertEntityNonLocked --- vault/identity_store_util.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/vault/identity_store_util.go b/vault/identity_store_util.go index b119f0e55f..cab839919f 100644 --- a/vault/identity_store_util.go +++ b/vault/identity_store_util.go @@ -324,6 +324,23 @@ func (i *IdentityStore) upsertEntity(entity *identity.Entity, previousEntity *id return nil } +// upsertEntityNonLocked creates or updates an entity. The lock to modify the +// entity should be held before calling this function. +func (i *IdentityStore) upsertEntityNonLocked(entity *identity.Entity, previousEntity *identity.Entity, persist bool) error { + // Create a MemDB transaction to update both alias and entity + txn := i.db.Txn(true) + defer txn.Abort() + + err := i.upsertEntityInTxn(txn, entity, previousEntity, persist, true) + if err != nil { + return err + } + + txn.Commit() + + return nil +} + func (i *IdentityStore) MemDBUpsertAliasInTxn(txn *memdb.Txn, alias *identity.Alias, groupAlias bool) error { if txn == nil { return fmt.Errorf("nil txn")