From a085b67f865b8074bfd41800250c342c73b931ae Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Sun, 16 Dec 2012 17:18:20 +0000 Subject: prevent multiple 'index locked' notifications by keeping a "was locked" flag in the UI. Once changes are successfully flushed, we use a single "all clear" notification. --- alot/commands/globals.py | 8 +++++++- alot/ui.py | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/alot/commands/globals.py b/alot/commands/globals.py index 6509e554..9abadbe3 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -470,13 +470,19 @@ class FlushCommand(Command): if callable(self.callback): self.callback() logging.debug('flush complete') + if ui.db_was_locked: + ui.notify('changes flushed') + ui.db_was_locked = False + except DatabaseLockedError: timeout = settings.get('flush_retry_timeout') def f(*args): self.apply(ui) ui.mainloop.set_alarm_in(timeout, f) - ui.notify('index locked, will try again in %d secs' % timeout) + if not ui.db_was_locked: + ui.notify('index locked, will try again in %d secs' % timeout) + ui.db_was_locked = True ui.update() return diff --git a/alot/ui.py b/alot/ui.py index 0fa94bc9..6f6d29ed 100644 --- a/alot/ui.py +++ b/alot/ui.py @@ -29,6 +29,8 @@ class UI(object): """points to currently active :class:`~alot.buffers.Buffer`""" dbman = None """Database Manager (:class:`~alot.db.manager.DBManager`)""" + db_was_locked = False + """flag used to prevent multiple 'index locked' notifications""" mode = 'global' """interface mode identifier - type of current buffer""" commandprompthistory = [] -- cgit v1.2.3 From 45cc3cb0efd79d8cecee0676a0951d1f9a30bab1 Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Sun, 16 Dec 2012 17:37:30 +0000 Subject: bug on exit if index not synced --- alot/commands/globals.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/alot/commands/globals.py b/alot/commands/globals.py index 9abadbe3..7cdf401e 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -38,8 +38,10 @@ class ExitCommand(Command): """shut down cleanly""" @inlineCallbacks def apply(self, ui): - if settings.get('bug_on_exit'): - if (yield ui.choice('realy quit?', select='yes', cancel='no', + msg = 'index not fully synced. ' if ui.db_was_locked else '' + if settings.get('bug_on_exit') or ui.db_was_locked: + msg += 'really quit?' + if (yield ui.choice(msg, select='yes', cancel='no', msg_position='left')) == 'no': return for b in ui.buffers: -- cgit v1.2.3