summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--worker/notmuch/lib/database.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/worker/notmuch/lib/database.go b/worker/notmuch/lib/database.go
index 46a39bc..670130f 100644
--- a/worker/notmuch/lib/database.go
+++ b/worker/notmuch/lib/database.go
@@ -301,6 +301,20 @@ func (db *DB) makeThread(parent *types.Thread, msgs *notmuch.Messages,
for msgs.Next(&msg) {
msgID := msg.ID()
_, inQuery := valid[msgID]
+ var noReplies bool
+ replies, err := msg.Replies()
+ // Replies() returns an error if there are no replies
+ if err != nil {
+ noReplies = true
+ }
+ if !inQuery {
+ if noReplies {
+ continue
+ }
+ defer replies.Close()
+ parent = db.makeThread(parent, replies, valid)
+ continue
+ }
node := &types.Thread{
Uid: db.uidStore.GetOrInsert(msgID),
Parent: parent,
@@ -318,9 +332,7 @@ func (db *DB) makeThread(parent *types.Thread, msgs *notmuch.Messages,
lastSibling.NextSibling = node
}
lastSibling = node
- replies, err := msg.Replies()
- if err != nil {
- // if there are no replies it will return an error
+ if noReplies {
continue
}
defer replies.Close()