summaryrefslogtreecommitdiff
path: root/alot/db.py
diff options
context:
space:
mode:
authorpazz <patricktotzke@gmail.com>2011-07-09 22:24:29 +0100
committerpazz <patricktotzke@gmail.com>2011-07-09 22:24:29 +0100
commit16f1868a56403a11f6ee0f7830be04eff346d544 (patch)
treece1e7fe723780c90b36c1a25a9fbc88efb7813f4 /alot/db.py
parent8054b51610f3faf9d985c81b1793b8b046b74488 (diff)
make sure read-only mode dowsn't write
this is the first part of a fix for issur #13
Diffstat (limited to 'alot/db.py')
-rw-r--r--alot/db.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/alot/db.py b/alot/db.py
index 6377f422..05e8c313 100644
--- a/alot/db.py
+++ b/alot/db.py
@@ -27,6 +27,9 @@ import helper
DB_ENC = 'utf8'
+class DatabaseError(Exception):
+ pass
+
class DBManager:
"""
@@ -43,11 +46,14 @@ class DBManager:
"""
tries to flush all queued write commands to the index
"""
+ if self.ro:
+ raise DatabaseError('Readonly mode!')
if self.writequeue:
try:
mode = Database.MODE.READ_WRITE
db = Database(path=self.path, mode=mode)
except NotmuchError:
+ # TODO: decapsulate ui here. maybe use self.eventloop here
if self.ui: # let the mainloop call us again after timeout
timeout = config.getint('general', 'flush_retry_timeout')
self.ui.update()
@@ -86,6 +92,8 @@ class DBManager:
:param remove_rest: remove tags from matching messages before tagging
:type remove_rest: boolean
"""
+ if self.ro:
+ raise DatabaseError('Readonly mode!')
if remove_rest:
self.writequeue.append(('set', querystring, tags))
else:
@@ -101,6 +109,8 @@ class DBManager:
:param tags: a list of tags to be added
:type tags: list of str
"""
+ if self.ro:
+ raise DatabaseError('Readonly mode!')
self.writequeue.append(('untag', querystring, tags))
self.flush()