summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2012-09-23 14:56:41 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2012-09-23 14:58:01 +0100
commit51eb8265cb4a3f5e4f24e75e0b6c0ea46f66dc64 (patch)
tree603d6c189c768f08735f99b8532223d01d9c0e98
parent9749343bd9898992d433f4011f4f6fe2dc6ea245 (diff)
add callback parameter for FlushCommand
-rw-r--r--alot/commands/globals.py12
-rw-r--r--alot/db/manager.py2
2 files changed, 12 insertions, 2 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py
index 900aea4e..6509e554 100644
--- a/alot/commands/globals.py
+++ b/alot/commands/globals.py
@@ -456,9 +456,20 @@ class TagListCommand(Command):
@registerCommand(MODE, 'flush')
class FlushCommand(Command):
"""flush write operations or retry until committed"""
+ def __init__(self, callback=None, **kwargs):
+ """
+ :param callback: function to call after successful writeout
+ :type callback: callable
+ """
+ Command.__init__(self, **kwargs)
+ self.callback = callback
+
def apply(self, ui):
try:
ui.dbman.flush()
+ if callable(self.callback):
+ self.callback()
+ logging.debug('flush complete')
except DatabaseLockedError:
timeout = settings.get('flush_retry_timeout')
@@ -468,7 +479,6 @@ class FlushCommand(Command):
ui.notify('index locked, will try again in %d secs' % timeout)
ui.update()
return
- logging.debug('flush complete')
#TODO: choices
diff --git a/alot/db/manager.py b/alot/db/manager.py
index c52da7b2..3c938f9b 100644
--- a/alot/db/manager.py
+++ b/alot/db/manager.py
@@ -153,7 +153,7 @@ class DBManager(object):
if callable(afterwards):
logging.debug(str(afterwards))
afterwards()
- logging.debug('called callback')
+ logging.debug('called callback')
# re-insert item to the queue upon Xapian/NotmuchErrors
except (XapianError, NotmuchError) as e: