Commit notifications for all Sup repositories
 help / color / mirror / Atom feed
From: Dan Callaghan <dan@bl2.djc.id.au>
To: sup-commits@supmua.dev
Subject: [sup.git] 03/03: use MatchAll base query term instead of Kmail
Date: Mon, 05 Oct 2026 17:05:29 +1100	[thread overview]
Message-ID: <20261005060526.D043627DFD0@bl2.djc.id.au> (raw)
In-Reply-To: <179118032647.283567.18317622877648426558@bl2.djc.id.au>

New commit on branch develop:
https://supmua.dev/git/sup/commit/735593960308648000dbe99d706221c24a306746.html

commit 735593960308648000dbe99d706221c24a306746
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Mon Oct 5 14:29:38 2026 +1100

    use MatchAll base query term instead of Kmail
    
    Works around a spurious DatabaseCorruptError from Xapian, if no other
    terms are added to the query (as in the "all mail" listing).
    
    Xapian bug: https://trac.xapian.org/ticket/855
    
    Fixes #628 (with a workaround).
---
 Manifest.txt                   |  1 +
 lib/sup/index.rb               |  4 ++-
 test/integration/test_index.rb | 62 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/Manifest.txt b/Manifest.txt
index aaf1cc8b..a05e069e 100644
--- a/Manifest.txt
+++ b/Manifest.txt
@@ -173,6 +173,7 @@ test/gnupg_test_home/regen_keys.sh
 test/gnupg_test_home/secring.gpg
 test/gnupg_test_home/sup-test-2@foo.bar.asc
 test/integration/test_draft.rb
+test/integration/test_index.rb
 test/integration/test_maildir.rb
 test/integration/test_mbox.rb
 test/integration/test_sup-add.rb
diff --git a/lib/sup/index.rb b/lib/sup/index.rb
index a37eb0da..70afc8d7 100644
--- a/lib/sup/index.rb
+++ b/lib/sup/index.rb
@@ -674,7 +674,9 @@ EOS
     neglabels = [:spam, :deleted, :killed].reject { |l| (labels.include? l) || opts.member?("load_#{l}".intern) }
     pos_terms, neg_terms = [], []
 
-    pos_terms << mkterm(:type, 'mail')
+    ## workaround for https://trac.xapian.org/ticket/855
+    #pos_terms << mkterm(:type, 'mail')
+    pos_terms << Q::MatchAll
     pos_terms.concat(labels.map { |l| mkterm(:label,l) })
     pos_terms << opts[:qobj] if opts[:qobj]
     pos_terms << mkterm(:source_id, opts[:source_id]) if opts[:source_id]
diff --git a/test/integration/test_index.rb b/test/integration/test_index.rb
new file mode 100644
index 00000000..6dbeb59d
--- /dev/null
+++ b/test/integration/test_index.rb
@@ -0,0 +1,62 @@
+require "sup"
+require "test_helper"
+
+class TestIndexIntegration < Minitest::Test
+  include Redwood
+
+  def setup
+    @path = Dir.mktmpdir
+  end
+
+  def teardown
+    ObjectSpace.each_object(Class).select {|a| a < Redwood::Singleton}.each do |klass|
+      klass.deinstantiate! unless klass == Redwood::Logger
+    end
+    FileUtils.rm_r @path
+  end
+
+  def create_large_mbox n_messages
+    mbox = File.join @path, "big.mbox"
+    File.open(mbox, "w") do |f|
+      n_messages.times do |i|
+        ## spread the dates out so that the assigned docids are not
+        ## contiguous, as in a real index
+        date = Time.utc(2011) + i * 3600
+        f.write <<EOS
+From bob@example.com Sat Jan  1 00:00:00 2011
+From: Bob <bob@example.com>
+To: Joe <joe@example.com>
+Subject: message number #{i}
+Date: #{date.strftime "%a, %d %b %Y %H:%M:%S +0000"}
+Message-ID: <message-#{i}@example.com>
+
+Hi Bob, this is test message #{i}. From Joe.
+
+EOS
+      end
+    end
+    mbox
+  end
+
+  def start_sup_and_add_source source
+    start
+    Logger.remove_sink $stderr
+    Index.init @path
+    Index.load
+    SourceManager.instance.instance_eval '@sources = {}'
+    SourceManager.instance.add_source source
+    PollManager.poll_from source
+    Index.save_index
+  end
+
+  def test_all_mail_query
+    n_messages = 1200
+    mbox = create_large_mbox n_messages
+    start_sup_and_add_source MBox.new "mbox:#{mbox}"
+
+    ## the empty query is the "all mail" listing
+    ids = []
+    Index.each_id({}) { |id| ids << id }
+    assert_equal n_messages, ids.size
+  end
+end

      parent reply	other threads:[~2026-10-05  6:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-05  6:05 [sup.git] branch develop updated (1aae17f2 -> 73559396) Dan Callaghan
2026-10-05  6:05 ` [sup.git] 01/03: contrib/nix: add Ruby shells as gc roots Dan Callaghan
2026-10-05  6:05 ` [sup.git] 02/03: contrib/nix/test-all-rubies.sh: add Ruby 4.0 Dan Callaghan
2026-10-05  6:05 ` Dan Callaghan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261005060526.D043627DFD0@bl2.djc.id.au \
    --to=dan@bl2.djc.id.au \
    --cc=djc@djc.id.au \
    --cc=sup-commits@supmua.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox