summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alot/account.py3
-rw-r--r--alot/db.py19
2 files changed, 9 insertions, 13 deletions
diff --git a/alot/account.py b/alot/account.py
index 1a405df9..abd44db5 100644
--- a/alot/account.py
+++ b/alot/account.py
@@ -134,8 +134,7 @@ class Account(object):
# I wish the mailbox module were more helpful...
path = glob.glob(os.path.join(mbx._path, '*', message_id + '*'))[0]
- message = self.dbman.add_message(path)
- message.add_tags(tags)
+ message = self.dbman.add_message(path, tags)
self.dbman.flush()
return True
diff --git a/alot/db.py b/alot/db.py
index b6521e53..b7c05d46 100644
--- a/alot/db.py
+++ b/alot/db.py
@@ -289,23 +289,20 @@ class DBManager(object):
db = Database(path=self.path, mode=mode)
return db.create_query(querystring)
- def add_message(self, path):
+ def add_message(self, path, tags=[], afterwards=None):
"""
Adds a file to the notmuch index.
:param path: path to the file
:type path: str
- :returns: the message object corresponding the added message
- :rtype: :class:`alot.message.Message`
+ :param tags: tagstrings to add
+ :type tags: list of str
+ :param afterwards: callback to trigger after adding
+ :type afterwards: callable or None
"""
- db = Database(path=self.path, mode=Database.MODE.READ_WRITE)
- try:
- message, status = db.add_message(path,
- sync_maildir_flags=True)
- except NotmuchError as e:
- raise DatabaseError(unicode(e))
-
- return Message(self, message)
+ if self.ro:
+ raise DatabaseROError()
+ self.writequeue.append(('add', afterwards, path, tags))
def remove_message(self, message):
"""