diff options
author | Lars Wirzenius <liw@liw.fi> | 2012-04-21 12:39:58 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2012-04-21 12:39:58 +0100 |
commit | d9f1bf2fad560b0dd592383a92d1903fbce8f50e (patch) | |
tree | 37071cb5ec3529d1a4f4a7adcf569b076b7b66e0 | |
parent | c12b5cbebc084dc475b7c7690bc0831110323811 (diff) | |
download | larch-d9f1bf2fad560b0dd592383a92d1903fbce8f50e.tar.gz |
Do not do commit or rollback when opening a journal in read-only mode
-rw-r--r-- | larch/journal.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/larch/journal.py b/larch/journal.py index eef0a43..b6b7eb9 100644 --- a/larch/journal.py +++ b/larch/journal.py @@ -76,12 +76,13 @@ class Journal(object): self.flag_file = os.path.join(self.storedir, self.flag_basename) self.new_flag = os.path.join(self.newdir, self.flag_basename) - if self.fs.exists(self.new_flag): - logging.debug('Automatically committing remaining changes') - self.commit() - else: - logging.debug('Automatically rolling back remaining changes') - self.rollback() + if self.allow_writes: + if self.fs.exists(self.new_flag): + logging.debug('Automatically committing remaining changes') + self.commit() + else: + logging.debug('Automatically rolling back remaining changes') + self.rollback() def _require_rw(self): '''Raise error if modifications are not allowed.''' |