From: Michael J Gruber <michaeljgruber+grubix+git@gmail.com>
To: David Bremner <david@tethera.net>
Cc: frederik@ofb.net, notmuch@notmuchmail.org
Subject: Re: searching for a message by path
Date: Mon, 14 Oct 2024 08:50:23 +0200 [thread overview]
Message-ID: <CAA19uiRF+nh_gxx4wL3daVJ2V_7FPbOOSQD_9CTf2-1D5ix4XA@mail.gmail.com> (raw)
In-Reply-To: <874j5hdj1a.fsf@tethera.net>
Am So., 13. Okt. 2024 um 00:59 Uhr schrieb David Bremner <david@tethera.net>:
>
> David Bremner <david@tethera.net> writes:
>
> > Frederick Eaton <frederik@ofb.net> writes:
> >
> >> If Notmuch is meant to function as an abstraction layer over message
> >> files stored on the file system, then why doesn't it provide a
> >> standard way to go from file paths to Notmuch messages?
> >
> > Although I think notmuch as it exists is far from "an abstraction
> > layer", the specific feature request seems reasonable. It would need
> > someone who wants it to get familiar with the low level implementation
> > details of notmuch. In particular it would require writing a database
> > upgrade and having a new version of the database schema.
>
> I was looking at the code, and I realized it is not actually as hard as
> that. Essentially the code of notmuch_database_find_message_by_filename
> needs to be wrapped in a PostingSource following the model of
> RegexpPostingSource (regexp-fields.cc). The fact that no database format
> changes (or even reindexing) are needed, makes this a much lower risk
> project.
If you want to map filenames to mids, you can use xapian.
Say, $relone is the filename path relative to the notmuch basedir
~/.mail/.notmuch/.
```
dirterm=XDIRECTORY$(dirname $relone)
dirdocid=$(xapian-delve -1 -t $dirterm ~/.mail/.notmuch/xapian/ | tail -n1)
docterm=XFDIRENTRY${dirdocid}:$(basename $relone)
docid=$(xapian-delve -1 -t $docterm ~/.mail/.notmuch/xapian/ | tail -n1)
xapian-delve -1 -t $docterm -r $docid -V1 ~/.mail/.notmuch/xapian/ |
grep Value | cut -d' ' -f6-
```
... or grep Message-ID :)
Cheers
Michael
next prev parent reply other threads:[~2024-10-14 6:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-20 17:52 searching for a message by path Frederick Eaton
2024-09-21 0:25 ` Pengji Zhang
2024-09-21 3:23 ` Frederick Eaton
2024-09-21 9:01 ` Pengji Zhang
2024-09-21 9:38 ` Michael J Gruber
2024-09-21 10:44 ` Gregor Zattler
2024-09-21 16:24 ` Panayotis Manganaris
2024-09-21 17:30 ` Teemu Likonen
2024-09-23 22:14 ` Panayotis Manganaris
2024-09-24 13:00 ` David Bremner
2024-09-24 9:09 ` Michael J Gruber
2024-09-28 2:56 ` Frederick Eaton
2024-09-29 12:08 ` David Bremner
2024-10-12 22:59 ` David Bremner
2024-10-14 6:50 ` Michael J Gruber [this message]
2024-10-14 10:58 ` David Bremner
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
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAA19uiRF+nh_gxx4wL3daVJ2V_7FPbOOSQD_9CTf2-1D5ix4XA@mail.gmail.com \
--to=michaeljgruber+grubix+git@gmail.com \
--cc=david@tethera.net \
--cc=frederik@ofb.net \
--cc=notmuch@notmuchmail.org \
/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.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).