diff options
author | pazz <patricktotzke@gmail.com> | 2011-07-09 22:24:29 +0100 |
---|---|---|
committer | pazz <patricktotzke@gmail.com> | 2011-07-09 22:24:29 +0100 |
commit | 16f1868a56403a11f6ee0f7830be04eff346d544 (patch) | |
tree | ce1e7fe723780c90b36c1a25a9fbc88efb7813f4 /alot/db.py | |
parent | 8054b51610f3faf9d985c81b1793b8b046b74488 (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.py | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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() |