purebred-mua / hs-notmuch

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

implement index/remove file capability #35

Closed frasertweedale closed 5 years ago

frasertweedale commented 5 years ago

Also a few minor drive-by fixes.

Changes:

70f1887 (Fraser Tweedale, 29 minutes ago)
   add hs-notmuch-index-file program

   Add the hs-notmuch-index-file program to demonstrate and test indexFile and
   removeFile.

   Related: https://github.com/purebred-mua/hs-notmuch/issues/34

df0a8b3 (Fraser Tweedale, 30 minutes ago)
   add removeFile

   Fixes: https://github.com/purebred-mua/hs-notmuch/issues/34

5279fbc (Fraser Tweedale, 2 hours ago)
   add indexFile

   Part of: https://github.com/purebred-mua/hs-notmuch/issues/34

7fa3c03 (Fraser Tweedale, 2 hours ago)
   withFrozenMessage: exclude thaw in computation

   Use RankNTypes to require the computation argument to work for any degree
   of frozenness:

     withFrozenMessage
      :: (forall n. Message n RW -> IO a)
      -> Message 0 RW
      -> IO a

   The thaw function:

     message_thaw
      :: (1 <= n)
      => Message n RW -> IO (Message (n - 1) RW)

   is thereby excluded from the inner computation.

d13f349 (Fraser Tweedale, 2 hours ago)
   .gitignore: add cabal v2 artifacts

32edfdc (Fraser Tweedale, 8 hours ago)
   hs-notmuch-tag-set: fix description

53d09af (Fraser Tweedale, 19 hours ago)
   support non-error nonzero status scenarios

   For some libnotmuch routines, a nonzero status doesn't necessarily mean
   error.  For example, notmuch_database_index_file returns 
   NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID when message ID was already in the
   database, and it is considered a success case.

   Add variants of 'status' and 'constructF' that take a predicate to 
   discriminate success and failure statuses, for use in such scenarios.

   Part of: https://github.com/purebred-mua/hs-notmuch/issues/34
frasertweedale commented 5 years ago

@romanofski here it is, but I still need to update docs and CI because our libnotmuch minimum support version increases. You might be able to start paying with this as-is, though.

romanofski commented 5 years ago

w00t - let me try it out

romanofski commented 5 years ago

Just so to let you know. I've just started building the purebred integration side in order to get the mails indexed and tagged.

If you're keen merge ho :)

romanofski commented 5 years ago

I've tried it in my current branch and it works nicely. The only thing I've noticed is that removing the mail from the index is called removeFile. Basically the same as we use for removing a file from the file system.

I'll remove the mail from the index and remove the file from the file system in purebred. It did feel a bit weird. Anyway, everything else seems to work as intended. Good stuff!

Current WIP is at: https://github.com/purebred-mua/purebred/tree/feature/119DraftsInSecureDirectory

frasertweedale commented 5 years ago

I've tried it in my current branch and it works nicely. The only thing I've noticed is that removing the mail from the index is called removeFile. Basically the same as we use for removing a file from the file system.

Yeah I'm just following the naming convention from libnotmuch. It makes sense when you understand that the primary behaviour is dissociating a file from a message (which may have multiple files associated with it), with the message itself being unindexed as a seconary behaviour only when the last file association is removed.

I don't care if there's a name conflict, can always qualify the import :)

frasertweedale commented 5 years ago

@romanofski thanks for reviewing. I'll try and polish this off this weekend or sometime next week.

romanofski commented 5 years ago

@frasertweedale sweet! Let me know when you bumped the version so the builds don't fail on the purebred side :)

frasertweedale commented 5 years ago

@romanofski I added the path sanity checking. Please test it and if you're happy, we can merge. Then I'll bump version and cut a release.

romanofski commented 5 years ago

I've updated and ran the tests and while there is a test failure when it comes to left over mails in the Drafts folder, I think it works and can be merged. If you want, let me have a closer look at the single failure tonight but seems your changes are not the problem.

romanofski commented 5 years ago

Looking good: https://travis-ci.org/purebred-mua/purebred/jobs/542682578 Merge away!