~emersion/soju-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] Make DB.DeleteChannel take the channel ID

Details
Message ID
<20200906150042.74130-1-hubert@hirtzfr.eu>
DKIM signature
pass
Download raw message
Patch: +7 -3
... to allow the caller to correctly do any necessary casemapping.
---
 db.go   | 4 ++--
 user.go | 6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/db.go b/db.go
index 46d04df..1aeccec 100644
--- a/db.go
+++ b/db.go
@@ -461,10 +461,10 @@ func (db *DB) StoreChannel(networkID int64, ch *Channel) error {
	return err
}

func (db *DB) DeleteChannel(networkID int64, name string) error {
func (db *DB) DeleteChannel(id int64) error {
	db.lock.Lock()
	defer db.lock.Unlock()

	_, err := db.db.Exec("DELETE FROM Channel WHERE network = ? AND name = ?", networkID, name)
	_, err := db.db.Exec("DELETE FROM Channel WHERE id = ?", id)
	return err
}
diff --git a/user.go b/user.go
index 021e5b6..aded19c 100644
--- a/user.go
+++ b/user.go
@@ -229,7 +229,11 @@ func (net *network) createUpdateChannel(ch *Channel) error {
}

func (net *network) deleteChannel(name string) error {
	if err := net.user.srv.db.DeleteChannel(net.ID, name); err != nil {
	ch, ok := net.channels[name]
	if !ok {
		return fmt.Errorf("unknown channel %q", name)
	}
	if err := net.user.srv.db.DeleteChannel(ch.ID); err != nil {
		return err
	}
	delete(net.channels, name)
-- 
2.28.0
Details
Message ID
<8MDr1jlIXWlH60WbB00m1Ao4qy4fZRUwpga35iCoGsHud6_n9-h0JKSYZMGwhmb10Ow9y7AXP25-K9vYdnv-B5U3Cs7p3JvFLeQUbijjNIY=@emersion.fr>
In-Reply-To
<20200906150042.74130-1-hubert@hirtzfr.eu> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
LGTM, pushed, thanks!
Review patch Export thread (mbox)