[PATCH 2/1 v2] UIDMaps: ensure we don't update the map file in dry run mode

Nicolas Sebrecht nicolas.s-dev at laposte.net
Mon Oct 24 18:09:18 UTC 2016


Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/380
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev at laposte.net>
---
 offlineimap/folder/UIDMaps.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/offlineimap/folder/UIDMaps.py b/offlineimap/folder/UIDMaps.py
index cc4d84a..328ce7c 100644
--- a/offlineimap/folder/UIDMaps.py
+++ b/offlineimap/folder/UIDMaps.py
@@ -33,6 +33,7 @@ class MappedIMAPFolder(IMAPFolder):
     be an IMAPFolder.
 
     Instance variables (self.):
+      dryrun: boolean.
       dofsync: boolean for fsync calls.
       r2l: dict mapping message uids: self.r2l[remoteuid]=localuid
       l2r: dict mapping message uids: self.r2l[localuid]=remoteuid
@@ -42,6 +43,7 @@ class MappedIMAPFolder(IMAPFolder):
 
     def __init__(self, *args, **kwargs):
         IMAPFolder.__init__(self, *args, **kwargs)
+        self.dryrun = self.config.getdefaultboolean("general", "dry-run", True)
         self.dofsync = self.config.getdefaultboolean("general", "fsync", True)
         self.maplock = Lock()
         self.diskr2l, self.diskl2r = self._loadmaps()
@@ -94,6 +96,9 @@ class MappedIMAPFolder(IMAPFolder):
             return (r2l, l2r)
 
     def _savemaps(self):
+        if self.dryrun is True:
+            return
+
         mapfilename = self._getmapfilename()
         # Do not use the map file directly to prevent from leaving it truncated.
         mapfilenametmp = "%s.tmp"% mapfilename
@@ -136,7 +141,6 @@ class MappedIMAPFolder(IMAPFolder):
         with self.maplock:
             # OK.  Now we've got a nice list.  First, delete things from the
             # summary that have been deleted from the folder.
-
             for luid in self.diskl2r.keys():
                 if not luid in reallist:
                     ruid = self.diskl2r[luid]
-- 
2.10.0




More information about the OfflineIMAP-project mailing list