dodo
dodo copied to clipboard
IndexError when viewing inexistent message
When viewing a message that's in the mail directory, but (I think?) not yet indexed by notmuch new, dodo crashes with:
Error opening /home/florian/mail/news/new/1685093528_0.355627.aragog,U=453271,FMD5=508c75c8507a2ae5223dfd2faeb98122:2,: No such file or directory
Error opening /home/florian/mail/news/new/1685094428_0.359005.aragog,U=453273,FMD5=508c75c8507a2ae5223dfd2faeb98122:2,: No such file or directory
Traceback (most recent call last):
File "/home/florian/proj/dodo/dodo/mainwindow.py", line 63, in panel_focused
if w.dirty: w.refresh()
^^^^^^^^^^^
File "/home/florian/proj/dodo/dodo/thread.py", line 358, in refresh
m = self.model.message_at(self.current_message)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/florian/proj/dodo/dodo/thread.py", line 201, in message_at
return self.message_list.get(i, {})
^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'get'
due to this rather interesting output:
$ notmuch show --format=json --verify --include-html 0000000000052d67
Error opening /home/florian/mail/news/new/1685093528_0.355627.aragog,U=453271,FMD5=508c75c8507a2ae5223dfd2faeb98122:2,: No such file or directory
Error opening /home/florian/mail/news/new/1685094428_0.359005.aragog,U=453273,FMD5=508c75c8507a2ae5223dfd2faeb98122:2,: No such file or directory
[[[[[[]]]]]]
which results in self.message_list to be [] after flattening.
Using a default when getting the message instead:
diff --git i/dodo/thread.py w/dodo/thread.py
index f7d2be9..f4655f4 100644
--- i/dodo/thread.py
+++ w/dodo/thread.py
@@ -198,8 +198,11 @@ def refresh(self) -> None:
def message_at(self, i: int) -> dict:
"""A JSON object describing the i-th message in the (flattened) thread"""
-
- return self.message_list[i]
+ try:
+ return self.message_list[i]
+ except IndexError:
+ # notmuch failed
+ return {}
def default_message(self) -> int:
"""Return the index of either the oldest unread message or the last message
results in dodo displaying an empty message:
though ideally I suppose this would maybe display some sort of error message, or even the stderr of the notmuch call.