From b363a01a6f27ac8f081cbcaf4a23f1a1384e4ea1 Mon Sep 17 00:00:00 2001 From: Alex Jaspersen Date: Mon, 4 May 2020 02:20:28 +0000 Subject: [PATCH] Read accounts and grouped nicks in same transaction. --- irc/accounts.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/irc/accounts.go b/irc/accounts.go index d5cc962f..99e1239a 100644 --- a/irc/accounts.go +++ b/irc/accounts.go @@ -1050,21 +1050,23 @@ func (am *AccountManager) AuthenticateByPassphrase(client *Client, accountName s // AllNicks returns the uncasefolded nicknames for all accounts, including additional (grouped) nicks. func (am *AccountManager) AllNicks() (result []string) { - // Account names accountNamePrefix := fmt.Sprintf(keyAccountName, "") + accountAdditionalNicksPrefix := fmt.Sprintf(keyAccountAdditionalNicks, "") + am.server.store.View(func(tx *buntdb.Tx) error { - return tx.AscendGreaterOrEqual("", accountNamePrefix, func(key, value string) bool { + // Account names + err := tx.AscendGreaterOrEqual("", accountNamePrefix, func(key, value string) bool { if !strings.HasPrefix(key, accountNamePrefix) { return false } result = append(result, value) return true }) - }) + if err != nil { + return err + } - // Additional nicknames - accountAdditionalNicksPrefix := fmt.Sprintf(keyAccountAdditionalNicks, "") - am.server.store.View(func(tx *buntdb.Tx) error { + // Additional nicks return tx.AscendGreaterOrEqual("", accountAdditionalNicksPrefix, func(key, value string) bool { if !strings.HasPrefix(key, accountAdditionalNicksPrefix) { return false