From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by bl2.djc.id.au (Postfix, from userid 1000) id D043627DFD0; Mon, 05 Oct 2026 17:05:26 +1100 (AEDT) Date: Mon, 05 Oct 2026 17:05:29 +1100 To: sup-commits@supmua.dev Subject: [sup.git] 03/03: use MatchAll base query term instead of Kmail MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Reply-To: Dan Callaghan In-Reply-To: <179118032647.283567.18317622877648426558@bl2.djc.id.au> References: <179118032647.283567.18317622877648426558@bl2.djc.id.au> Thread-Index: AQAAEjRWLL+Zs0RlTBOXqabHikqx6w== X-Git-Host: bl2.djc.id.au X-Git-Repo: sup.git X-Git-Refname: refs/heads/develop X-Git-Reftype: branch X-Git-Rev: 735593960308648000dbe99d706221c24a306746 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.7.dev Auto-Submitted: auto-generated Message-Id: <20261005060526.D043627DFD0@bl2.djc.id.au> From: Dan Callaghan List-Id: New commit on branch develop: https://supmua.dev/git/sup/commit/735593960308648000dbe99d706221c24a306746.html commit 735593960308648000dbe99d706221c24a306746 Author: Dan Callaghan 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 < +To: Joe +Subject: message number #{i} +Date: #{date.strftime "%a, %d %b %Y %H:%M:%S +0000"} +Message-ID: + +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