Commit fcb0bdc8 authored by Leon's avatar Leon Committed by Sietse Ringers

Add request changes by Ivar

parent 93cc39d6
Pipeline #39625 canceled with stages
in 52 seconds
......@@ -335,18 +335,16 @@ func (client *Client) RemoveCredentialByHash(hash string) error {
// Includes the user's secret key, keyshare servers and preferences/updates
// A fresh secret key is installed.
func (client *Client) RemoveStorage() error {
var err error
// Remove data from memory
client.attributes = make(map[irma.CredentialTypeIdentifier][]*irma.AttributeList)
client.keyshareServers = make(map[irma.SchemeManagerIdentifier]*keyshareServer)
client.credentialsCache = make(map[irma.CredentialTypeIdentifier]map[int]*credential)
err := client.storage.Transaction(func(tx *transaction) error {
if err := client.storage.TxDeleteAll(tx); err != nil {
return err
}
return nil
})
if err = client.storage.DeleteAll(); err != nil {
return err
}
// Client assumes there is always a secret key, so we have to load a new one
client.secretkey, err = client.storage.LoadSecretKey()
......@@ -354,6 +352,7 @@ func (client *Client) RemoveStorage() error {
return err
}
// TODO: do we consider this setting as user data?
if client.Preferences, err = client.storage.LoadPreferences(); err != nil {
return err
}
......
......@@ -66,7 +66,7 @@ func (s *storage) Close() error {
}
func (s *storage) BucketExists(name []byte) bool {
return s.Transaction(func(tx *transaction) error {
return s.db.View(func(tx *bbolt.Tx) error {
if tx.Bucket(name) == nil {
return bbolt.ErrBucketNotFound
}
......@@ -372,3 +372,9 @@ func (s *storage) TxDeleteAll(tx *transaction) error {
}
return nil
}
func (s *storage) DeleteAll() error {
return s.Transaction(func(tx *transaction) error {
return s.TxDeleteAll(tx)
})
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment