summaryrefslogtreecommitdiff
path: root/alot/db/thread.py
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-01-20 20:31:49 +0100
committerAnton Khirnov <anton@khirnov.net>2021-01-20 20:31:49 +0100
commit180d6c5e439bfca2af479b445afff9b18e28df5a (patch)
treee87a716cf1ae05a3aec4f6c635edf7bfb27da7d6 /alot/db/thread.py
parentcc1ee21e0704d7f02552f1617737f6cf7471fa52 (diff)
db: make sure to close the read-only database instances
Diffstat (limited to 'alot/db/thread.py')
-rw-r--r--alot/db/thread.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/alot/db/thread.py b/alot/db/thread.py
index 1f9ae7f0..37cc5fc7 100644
--- a/alot/db/thread.py
+++ b/alot/db/thread.py
@@ -61,13 +61,10 @@ class Thread:
self.message_list = []
self.messages = {}
- self.refresh(thread)
+ self._refresh(thread)
- def refresh(self, thread = None):
+ def _refresh(self, thread):
"""refresh thread metadata from the index"""
- if not thread:
- thread = self._dbman._get_notmuch_thread(self.id)
-
self.total_messages = len(thread)
self._notmuch_authors_string = thread.authors
@@ -97,6 +94,11 @@ class Thread:
self.messages, self.toplevel_messages, self.message_list = self._gather_messages(thread)
+ def refresh(self):
+ with self._dbman._db_ro() as db:
+ thread = self._dbman._get_notmuch_thread(db, self.id)
+ self._refresh(thread)
+
def _gather_messages(self, thread):
msgs = {}
msg_tree = []