Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MessageNotFound after new mail was sent #395

Closed
romanofski opened this issue May 6, 2020 · 7 comments · Fixed by #402
Closed

MessageNotFound after new mail was sent #395

romanofski opened this issue May 6, 2020 · 7 comments · Fixed by #402
Labels
Milestone

Comments

@romanofski
Copy link
Member

Describe the bug
When I sent an email, the view goes back to the list of threads. When I try to re-open the same message, I get a MessageNotFound error. For example:

MessageNotFound "notmuch-sha1-37d366f6ef51d6b94836805748103ec126d391c8"

To Reproduce
Steps to reproduce the behavior:

  1. (Perhaps a custom query needs to be executed first)
  2. Compose a new mail from an old mail by opening a thread and pressing e.
  3. Sent the mail.
  4. Back on the thread view try to open the thread again.

Custom query first:

  1. Use a custom query to find a few threads: e.g. to:
  2. Start the composition from there

Expected behavior
Not a MessageNotFound error.

Screenshots
None

Additional context
Typically I reload the thread list after going back. Perhaps the keybindings are configured like that too and should be investigated.

@romanofski romanofski added the bug label May 6, 2020
@romanofski romanofski added this to the 1.0 milestone May 6, 2020
@romanofski
Copy link
Member Author

Just checked with composing a new mail from the default query after start up, and the problem doesn't exist once the mail is sent and Purebred went back to the threads view.

@romanofski
Copy link
Member Author

I think it has something to do with the mail being sent, falling into the result list of the search the threadview is set to. For example if the search is to:john and we're sending a new mail to john, the thread list is now obsolete, since the just sent mail isn't included ...

@romanofski
Copy link
Member Author

This one is nasty. The source of the problem is the composeAsNew action, which removes the file path from the notmuch index. I guess that's what we want when dealing with draft mails, since the drafts are getting removed and turned into mails we want to sent. However, not really something we want to do for existing mails, like mails we've sent.

So in this instance, what happens is, that the mail is removed from the index. The mail is composed as new, changed, sent and re-indexed. The view returns to the original query and obviously the original mail we created a new compose from doesn't exist any more.

@frasertweedale
Copy link
Member

@romanofski can we handle it in a similar way to how we update tags on the NotmuchMail after editing. But instead of just modifying the selected NotmuchMail on the thread view, we replace it with a new one?

@frasertweedale
Copy link
Member

Hm I see the problem... OK here's another idea. The message "key" in libnotmuch is the MessageID. If we write (and index) draft mail with message ID, and keep that message ID the same for composeAsNew, then indexing and removal can just remove files from the libnotmuch message object, rather than removing the message from the notmuch db then adding a new one. Then the same message object previously referred to shall still exist.

Maybe I am misunderstanding the scenario... but let me know what you think.

@romanofski
Copy link
Member Author

It depends really, because for draft mails, we would want to remove them from the index as long as they're sent (I would think?). thinks
With your last comment, perhaps we don't, but rather just change the tags (from draft to sent). Generally speaking just updating the database of the mail. Is that what you meant?

I think my initial mental model was to literally unindex and delete the files. But having the drafts around until the mail is sent is actually a good thing (just to avoid loosing your mail).

@romanofski
Copy link
Member Author

I think the trouble is with the underlying file management and the semantics with the action: use the current mail as a template to compose a new mail.

For drafts, essentially the file path changes. We move the mail from Drafts/new to Sent (if the mail ends up sending). This workflow isn't fully implemented yet, but half way there if we don't discard the composition but keep it as a draft (see #351).

For any other mails, this action should make a copy of the existing mail to create a new composition.

What I'm currently not sure about is whether a single action/keybinding should implicitly figure this out or whether we're better of using two separate actions/keybindings.

romanofski added a commit that referenced this issue Jun 23, 2020
romanofski added a commit that referenced this issue Jun 23, 2020
Initially composeAsNew was implemented with the idea to continue draft
mails. The mails are stored in the file system and indexed in
notmuch. Once the draft is picked up again, the mail is unindexed and
removed from the file system until it's sent.

However, if we use the same function on existing mails in order to
use the mail as a template for a new mail, we actually unindex and
remove the mail mistakenly from notmuch and the file system. Instead all
we want is a copy for composing.

This is a workaround for now, since ideally we want to keep all
compositions as a draft on the file system (see #351).

This patch only unindexes/removes draft mails, any other mail contents
are simply copied for composition.

Fixes #395
romanofski added a commit that referenced this issue Jun 23, 2020
romanofski added a commit that referenced this issue Jun 23, 2020
Initially composeAsNew was implemented with the idea to continue draft
mails. The mails are stored in the file system and indexed in
notmuch. Once the draft is picked up again, the mail is unindexed and
removed from the file system until it's sent.

However, if we use the same function on existing mails in order to
use the mail as a template for a new mail, we actually unindex and
remove the mail mistakenly from notmuch and the file system. Instead all
we want is a copy for composing.

This is a workaround for now, since ideally we want to keep all
compositions as a draft on the file system (see #351).

This patch only unindexes/removes draft mails, any other mail contents
are simply copied for composition.

Fixes #395
romanofski added a commit that referenced this issue Jun 24, 2020
romanofski added a commit that referenced this issue Jun 24, 2020
Initially composeAsNew was implemented with the idea to continue draft
mails. The mails are stored in the file system and indexed in
notmuch. Once the draft is picked up again, the mail is unindexed and
removed from the file system until it's sent.

However, if we use the same function on existing mails in order to
use the mail as a template for a new mail, we actually unindex and
remove the mail mistakenly from notmuch and the file system. Instead all
we want is a copy for composing.

This is a workaround for now, since ideally we want to keep all
compositions as a draft on the file system (see #351).

This patch only unindexes/removes draft mails, any other mail contents
are simply copied for composition.

Fixes #395
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants