purebred-mua / hs-notmuch

Modern Haskell binding to the Notmuch mail indexer
11 stars 2 forks source link

Expose a way to add files to notmuch #34

Closed romanofski closed 5 years ago

romanofski commented 5 years ago

While working on https://github.com/purebred-mua/purebred/issues/119 I can now write mails into a Drafts directory. But they're not indexed just by writing them there. Unless I do a subprocess call to notmuch new which will have other side effects, I think it would be good to leverage the use of hs-notmuch and expose the API to add messages with the given tags to the index. That way I can pick draft mails up again with a simple search (e.g. tag:draft)

frasertweedale commented 5 years ago

We can use notmuch_database_index_file but apparently the file must be under the database path (see https://git.notmuchmail.org/git?p=notmuch;a=blob;f=lib/notmuch.h;hb=HEAD#l561).

edit although I cannot see anything in the code to enforce that (haven't tried it yet tho)

romanofski commented 5 years ago

That's ok that the file has to be stored under the database path since I thought saving postponed mails in a folder under the database path.

I have not entirely figured out what to do in cases of IO exceptions, but perhaps in that case just writing it out as a temp file and not indexing it would be a way to go.

frasertweedale commented 5 years ago

Yeah save it under /tmp and alert the user (which needs an alert system of course).

romanofski commented 5 years ago

I've made progress on https://github.com/purebred-mua/purebred/issues/119 and realise that I can't finish the feature without this one. Kinda pointless to keep drafts around when you can't take them up again for sending.

I'll see if I can implement this one and see how I go.

frasertweedale commented 5 years ago

@romanofski I have a bit more time now that YLJ is over, I can probably tackle this, or certainly review your implementation if you already started.

romanofski commented 5 years ago

@frasertweedale nope haven't started yet. If you have time go for it. I'll concentrate on my refactorings instead.

frasertweedale commented 5 years ago

I have started chipping away at this.