From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id wGHVDRk0E2CRQgAA0tVLHw (envelope-from ) for ; Thu, 28 Jan 2021 22:00:57 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id GNx1CRk0E2AVFAAAbx9fmQ (envelope-from ) for ; Thu, 28 Jan 2021 22:00:57 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5A53694042F for ; Thu, 28 Jan 2021 22:00:56 +0000 (UTC) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 7173F28CC4; Thu, 28 Jan 2021 17:00:47 -0500 (EST) Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by mail.notmuchmail.org (Postfix) with ESMTPS id 351CF28CA2 for ; Thu, 28 Jan 2021 17:00:44 -0500 (EST) Received: by mail-pg1-x531.google.com with SMTP id n10so5200579pgl.10 for ; Thu, 28 Jan 2021 14:00:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dorileo-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BhdodkeLVFvkJ7n6ATYu7VIloMX2/kqKhIT/RZm7DIQ=; b=QubBOhpgG5VbZj7lEkCbKIrhsEbOqfiBx6hAqg+N5csqMxs/D2He2Hz3+6oDS0ZAoX sol6IVUG9nOJWt01OYw6TuZjD/CsetdqcTVmpvP0utdFaEsc+EjXWJ3bC7z7quRdwxCt 1nAHsYmWeAdI09+QnntbMAf2RiZYWwQn9AC8r51Ptx6GOUsaYh3juR0xzRAQAkCaqSUh gZwJHnZbaQQ05eWLH+5DJYL5HSIyM/BOl8bkKO+/WXrZ05c9tMvNnfh9tCe4OaVKq3xw Icx4h80lRkxnmOPd3nlxz4wG8OtaaPb4VDlox2qgmYRWyNzsg5gXL1jgojTFZcVCfy+d 85iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BhdodkeLVFvkJ7n6ATYu7VIloMX2/kqKhIT/RZm7DIQ=; b=XMZhYWHC2BUk6dyfQQ6BqeujctvqdLnCJ/vnDropjp64sUhpxYv8m5rrtIurkMDA8J Ylv26yC2iws/PnjbdyRet+MFD2T3GpI0OQRUPW5loBguk+ei4pIYe0uWd66SjY9f4a2x x/dULYplepo3YJxeagFchE8c94ZEH8/tU0skz5PFbNcW8Gclb+hUb1hYHPyrIt2gVBxd 98Wt3/pnWbBlHcpVANCFAg+sA5u2jJukc1Y88TeK4iRqbctw+vDIlp3PV6ZLCMkgYS1m ADZdQYzozgYYcYqjDawTAkoOYZ9Ppnd5vtRpJAqVejOOKOXhE+ps7Rn2kp0oIqqS/f6d s0kg== X-Gm-Message-State: AOAM5325/3/XBetBklxrILFsZ12seKeR7gjYZQedUFyH8jthaoDlIIXs zeQATy8BdBsLACtkFcnU2y2baQQYmrDowMrWXJA= X-Google-Smtp-Source: ABdhPJxR17qH97v0JY8DPpk+axZi/e9ehH58wDnmC9H6wUXpQKz/vhfQ9WDxnXNt/Q1oPEcWpMqFlQ== X-Received: by 2002:a62:7541:0:b029:1b9:c47e:7c14 with SMTP id q62-20020a6275410000b02901b9c47e7c14mr1573749pfc.30.1611871241640; Thu, 28 Jan 2021 14:00:41 -0800 (PST) Received: from dorilex.hsd1.or.comcast.net ([2601:1c0:6a01:6410::693f]) by smtp.gmail.com with ESMTPSA id 6sm6799632pgv.70.2021.01.28.14.00.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 14:00:39 -0800 (PST) From: Leandro Dorileo To: notmuch@notmuchmail.org Subject: [PATCH] contrib/go: update the go binding Date: Thu, 28 Jan 2021 14:00:22 -0800 Message-Id: <20210128220022.540983-1-l@dorileo.org> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Message-ID-Hash: 5XR3MZD42J2WOVNR3NYQPEI4LYXPD4NN X-Message-ID-Hash: 5XR3MZD42J2WOVNR3NYQPEI4LYXPD4NN X-MailFrom: l@dorileo.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Leandro Dorileo X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -0.04 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=dorileo-org.20150623.gappssmtp.com header.s=20150623 header.b=QubBOhpg; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 5A53694042F X-Spam-Score: -0.04 X-Migadu-Scanner: scn1.migadu.com X-TUID: aqKJH27yWgRz From: Leandro Dorileo Make sure to update the go binding to reflect the recent changes to notmuch api. Signed-off-by: Leandro Dorileo --- .../go/src/notmuch-addrlookup/addrlookup.go | 22 ++++++++++-- contrib/go/src/notmuch/notmuch.go | 34 +++++++++++-------- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/contrib/go/src/notmuch-addrlookup/addrlookup.go b/contrib/go/src/notmuch-addrlookup/addrlookup.go index 916e5bb2..b1023f24 100644 --- a/contrib/go/src/notmuch-addrlookup/addrlookup.go +++ b/contrib/go/src/notmuch-addrlookup/addrlookup.go @@ -130,7 +130,12 @@ func search_address_passes(queries [3]*notmuch.Query, name string) []string { //println("**warning: idx [",idx,"] contains a nil query") continue } - msgs := query.SearchMessages() + + msgs, status := query.SearchMessages() + if status != notmuch.STATUS_SUCCESS { + continue + } + ht := addresses_by_frequency(msgs, name, pass, &addr_to_realname) for addr, count := range *ht { freq, ok := addr_freq[addr] @@ -231,8 +236,21 @@ func (self *address_matcher) run(name string) { } queries[1] = self.db.CreateQuery(query) + cnt1, cnt2 := uint(0), uint(0) + status := notmuch.STATUS_SUCCESS + // if that leads only to a few hits, we check every from too - if queries[0].CountMessages()+queries[1].CountMessages() < 10 { + cnt1, status = queries[0].CountMessages() + if status != notmuch.STATUS_SUCCESS { + log.Fatalf("Failed to count messages: %v.", status) + } + + cnt2, status = queries[1].CountMessages() + if status != notmuch.STATUS_SUCCESS { + log.Fatalf("Failed to count messages: %v.", status) + } + + if cnt1+cnt2 < 10 { query = "" if name != "" { query = "from:" + name + "*" diff --git a/contrib/go/src/notmuch/notmuch.go b/contrib/go/src/notmuch/notmuch.go index 5496198a..c04c4c5a 100644 --- a/contrib/go/src/notmuch/notmuch.go +++ b/contrib/go/src/notmuch/notmuch.go @@ -255,10 +255,10 @@ func (self *Database) AddMessage(fname string) (*Message, Status) { return nil, STATUS_OUT_OF_MEMORY } - var c_msg *C.notmuch_message_t = new(C.notmuch_message_t) - st := Status(C.notmuch_database_add_message(self.db, c_fname, &c_msg)) + msg := &Message{message: nil} + st := Status(C.notmuch_database_add_message(self.db, c_fname, &msg.message)) - return &Message{message: c_msg}, st + return msg, st } /* Remove a message from the given notmuch database. @@ -454,12 +454,13 @@ func (self *Query) GetSort() Sort { * * If a Xapian exception occurs this function will return NULL. */ -func (self *Query) SearchThreads() *Threads { - threads := C.notmuch_query_search_threads(self.query) - if threads == nil { - return nil +func (self *Query) SearchThreads() (*Threads, Status) { + threads := &Threads{threads: nil} + st := Status(C.notmuch_query_search_threads(self.query, &threads.threads)) + if st != STATUS_SUCCESS { + return nil, st } - return &Threads{threads: threads} + return threads, st } /* Execute a query for messages, returning a notmuch_messages_t object @@ -500,12 +501,13 @@ func (self *Query) SearchThreads() *Threads { * * If a Xapian exception occurs this function will return NULL. */ -func (self *Query) SearchMessages() *Messages { - msgs := C.notmuch_query_search_messages(self.query) - if msgs == nil { - return nil +func (self *Query) SearchMessages() (*Messages, Status) { + msgs := &Messages{messages: nil} + st := Status(C.notmuch_query_search_messages(self.query, &msgs.messages)) + if st != STATUS_SUCCESS { + return nil, st } - return &Messages{messages: msgs} + return msgs, st } /* Destroy a notmuch_query_t along with any associated resources. @@ -530,8 +532,10 @@ func (self *Query) Destroy() { * If a Xapian exception occurs, this function may return 0 (after * printing a message). */ -func (self *Query) CountMessages() uint { - return uint(C.notmuch_query_count_messages(self.query)) +func (self *Query) CountMessages() (uint, Status) { + var cnt C.uint + st := Status(C.notmuch_query_count_messages(self.query, &cnt)) + return uint(cnt), st } /* Is the given 'threads' iterator pointing at a valid thread. -- 2.30.0