Skip to content

Commit

Permalink
local/state: load config and state after locking database
Browse files Browse the repository at this point in the history
this should prevent a possible race where a previous instance of gmi is
writing state while it is being loaded by this one.
  • Loading branch information
gauteh committed Oct 17, 2021
1 parent c7bc672 commit 87e85ef
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lieer/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,6 @@ def load_repository (self, block = False):
for mail_dir in ('cur', 'new', 'tmp')]):
raise Local.RepositoryException ('local repository not initialized: could not find mail dir structure')

self.config = Local.Config (self.config_f)
self.state = Local.State (self.state_f, self.config)

self.ignore_labels = self.ignore_labels | self.config.ignore_tags
self.update_translation('TRASH', self.config.local_trash_tag)
self.update_translation_list_with_overlay(self.config.translation_list_overlay)

## Check if we are in the notmuch db
with notmuch.Database () as db:
try:
Expand All @@ -357,6 +350,13 @@ def load_repository (self, block = False):
except OSError:
raise Local.RepositoryException ("failed to lock repository (probably in use by another gmi instance)")

self.config = Local.Config (self.config_f)
self.state = Local.State (self.state_f, self.config)

self.ignore_labels = self.ignore_labels | self.config.ignore_tags
self.update_translation('TRASH', self.config.local_trash_tag)
self.update_translation_list_with_overlay(self.config.translation_list_overlay)

self.__load_cache__ ()

# load notmuch config
Expand Down

0 comments on commit 87e85ef

Please sign in to comment.