libnetwork/internal/kvstore/boltdb: BoltDB.Exists(): fix error handling

This function could potentially return "true" even if an error was returned.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-07-02 20:17:21 +02:00
parent c94ccd4207
commit fb61b07bcf
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -220,8 +220,13 @@ func (b *BoltDB) Exists(key string) (bool, error) {
exists = len(bucket.Get([]byte(key))) > 0
return nil
})
return exists, err
if err != nil {
return false, err
}
if !exists {
return false, store.ErrKeyNotFound
}
return true, nil
}
// List returns the range of keys starting with the passed in prefix