[PATCH] Fix repository 'readonly' configuration
Sebastian Spaeth
Sebastian at SSpaeth.de
Thu Sep 15 11:06:06 BST 2011
The readonly feature was introduced to safeguard repositories from
accidental modifications. Unfortunately, my patch treated the readonly
setting as a string and not as a boolean, so if *anything* was set in
the configuration file as 'readonly', this value evaluated to True
Fortunately this was safe, we never treated a repository that we wanted
read-only as read-write. We always treated them readonly if something
was configured as "readonly=..." even if that was False.
The fix is simply to use getconfboolean() rather than getconf() which
checks for True/False/On/Off/yes/no/1/0 and hands back the correct boolean.
Reported-by: Tomasz Nowak <nowak2000 at poczta.onet.pl>
Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
---
Thanks to the digging by Tomasz, the fix was easy to spot.
My bad for treating a boolean configuration setting as string in the
first place.
offlineimap/accounts.py | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/offlineimap/accounts.py b/offlineimap/accounts.py
index 31ea2b7..428cbd8 100644
--- a/offlineimap/accounts.py
+++ b/offlineimap/accounts.py
@@ -231,7 +231,7 @@ class SyncableAccount(Account):
localrepos = self.localrepos
statusrepos = self.statusrepos
# replicate the folderstructure from REMOTE to LOCAL
- if not localrepos.getconf('readonly', False):
+ if not localrepos.getconfboolean('readonly', False):
self.ui.syncfolders(remoterepos, localrepos)
remoterepos.syncfoldersto(localrepos, statusrepos)
@@ -345,7 +345,7 @@ def syncfolder(accountname, remoterepos, remotefolder, localrepos,
remotefolder.getmessagecount())
# Synchronize remote changes.
- if not localrepos.getconf('readonly', False):
+ if not localrepos.getconfboolean('readonly', False):
ui.syncingmessages(remoterepos, remotefolder, localrepos, localfolder)
remotefolder.syncmessagesto(localfolder, statusfolder)
else:
@@ -353,7 +353,7 @@ def syncfolder(accountname, remoterepos, remotefolder, localrepos,
% localrepos.getname())
# Synchronize local changes
- if not remoterepos.getconf('readonly', False):
+ if not remoterepos.getconfboolean('readonly', False):
ui.syncingmessages(localrepos, localfolder, remoterepos, remotefolder)
localfolder.syncmessagesto(remotefolder, statusfolder)
else:
--
1.7.4.1
More information about the OfflineIMAP-project
mailing list