From fc3000d649d8df77d21b2dc297f069715e08f5eb Mon Sep 17 00:00:00 2001 From: Guillaume Ballet Date: Thu, 4 Apr 2019 20:06:40 +0200 Subject: more review feedback --- accounts/scwallet/hub.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'accounts/scwallet/hub.go') diff --git a/accounts/scwallet/hub.go b/accounts/scwallet/hub.go index 475305101..c259f711f 100644 --- a/accounts/scwallet/hub.go +++ b/accounts/scwallet/hub.go @@ -36,6 +36,7 @@ import ( "encoding/json" "io/ioutil" "os" + "path/filepath" "sort" "sync" "time" @@ -111,10 +112,11 @@ func (hub *Hub) readPairings() error { } func (hub *Hub) writePairings() error { - pairingFile, err := os.OpenFile(filepath.Join(hub.datadir,"smartcards.json"), os.O_RDWR|os.O_CREATE, 0755) + pairingFile, err := os.OpenFile(filepath.Join(hub.datadir, "smartcards.json"), os.O_RDWR|os.O_CREATE, 0755) if err != nil { return err } + defer pairingFile.Close() pairings := make([]smartcardPairing, 0, len(hub.pairings)) for _, pairing := range hub.pairings { @@ -130,15 +132,11 @@ func (hub *Hub) writePairings() error { return err } - return pairingFile.Close() + return nil } func (hub *Hub) pairing(wallet *Wallet) *smartcardPairing { - if pairing, ok := hub.pairings[string(wallet.PublicKey)]; ok{ - return &pairing - } - return nil - if ok { + if pairing, ok := hub.pairings[string(wallet.PublicKey)]; ok { return &pairing } return nil @@ -209,6 +207,7 @@ func (hub *Hub) refreshWallets() { // want to fill the user's log with errors, so filter those out. if err.Error() != "scard: Cannot find a smart card reader." { log.Error("Failed to enumerate smart card readers", "err", err) + return } } // Transform the current list of wallets into the new one -- cgit v1.2.3