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 _______________________________________________ notmuch mailing list -- notmuch@notmuchmail.org To unsubscribe send an email to notmuch-leave@notmuchmail.org