sync: redownload messages that disappear from the maildir #42
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If we detect a message that exists in notmuch, exists on the server, but is not in the maildir, treat it a little like a "new" message and redownload it from the server.
This is exploring a question that came out of the discussion on #33: what should mujmap do when confronted with a maildir that doesn't look quite right?
I think something like this is at least part of the right answer. notmuch is our local source of truth on what should exist. If it believes the message should exist, and the server doesn't have any changes on it, but its not in the maildir, that's clearly wrong and its no big deal to redownload the message.
I don't really think this is the "right" way to do this. Probably rather than weirdly forcing this into different points in the codepath, there should be an upfront flag on each
NewEmail
that indicates why we're doing the download. This was where I landed from just playing around though.This also opens up options for future sanity checking modes, for example once we have blob checksums (#36) we can detect broken mail files as well, not just non-existent ones.
Something I had to consider right up front was whether a message could be removed from the maildir as part of notmuch's normal operation. As far as I can tell from reading its code, the answer is no. The only thing in notmuch that will notice a missing message in a maildir is
notmuch new
. I'm assuming that since mujmap is doing the work of coordinating the maildir and the notmuch index,notmuch new
should not be in play. (If it is, then we have a bigger problem I think, because the index is no longer the source of truth).What do you think?