From: Leandro Dorileo <lean...@dorileo.org>

Make sure to update the go binding to reflect the recent changes to
notmuch api.

Signed-off-by: Leandro Dorileo <lean...@dorileo.org>
---
 .../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
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org

Reply via email to