mirror of
https://github.com/mitchell/selfpass.git
synced 2025-12-14 13:27:21 +00:00
Fix setting empty OTP secret; minor refactors
This commit is contained in:
parent
2096d6ada8
commit
e136b40b70
6 changed files with 33 additions and 30 deletions
|
|
@ -6,7 +6,6 @@ import (
|
|||
"encoding/gob"
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"go.etcd.io/bbolt"
|
||||
|
||||
|
|
@ -38,24 +37,19 @@ func (db BoltDB) GetAllMetadata(ctx context.Context, sourceHost string, errch ch
|
|||
return nil
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
c := bkt.hostPrimaryIndex.Cursor()
|
||||
|
||||
if sourceHost == "" {
|
||||
for key, value := c.First(); key != nil; key, value = c.Next() {
|
||||
wg.Add(1)
|
||||
unmarshalAndSendCred(value, mdch, errch, &wg)
|
||||
unmarshalAndSendCred(value, mdch, errch)
|
||||
}
|
||||
} else {
|
||||
hostBytes := []byte(sourceHost)
|
||||
for key, value := c.Seek(hostBytes); bytes.HasPrefix(key, hostBytes); key, value = c.Next() {
|
||||
wg.Add(1)
|
||||
unmarshalAndSendCred(value, mdch, errch, &wg)
|
||||
unmarshalAndSendCred(value, mdch, errch)
|
||||
}
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
|
|
@ -67,9 +61,7 @@ func (db BoltDB) GetAllMetadata(ctx context.Context, sourceHost string, errch ch
|
|||
return mdch
|
||||
}
|
||||
|
||||
func unmarshalAndSendCred(value []byte, mdch chan<- types.Metadata, errch chan<- error, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
|
||||
func unmarshalAndSendCred(value []byte, mdch chan<- types.Metadata, errch chan<- error) {
|
||||
var cred types.Credential
|
||||
|
||||
err := gobUnmarshal(value, &cred)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue