UIDMaps: ensure we don't update the map file in dry run mode
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/380 Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
2ac68d82aa
commit
41c9694488
@ -33,6 +33,7 @@ class MappedIMAPFolder(IMAPFolder):
|
|||||||
be an IMAPFolder.
|
be an IMAPFolder.
|
||||||
|
|
||||||
Instance variables (self.):
|
Instance variables (self.):
|
||||||
|
dryrun: boolean.
|
||||||
dofsync: boolean for fsync calls.
|
dofsync: boolean for fsync calls.
|
||||||
r2l: dict mapping message uids: self.r2l[remoteuid]=localuid
|
r2l: dict mapping message uids: self.r2l[remoteuid]=localuid
|
||||||
l2r: dict mapping message uids: self.r2l[localuid]=remoteuid
|
l2r: dict mapping message uids: self.r2l[localuid]=remoteuid
|
||||||
@ -42,6 +43,7 @@ class MappedIMAPFolder(IMAPFolder):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
IMAPFolder.__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.dofsync = self.config.getdefaultboolean("general", "fsync", True)
|
||||||
self.maplock = Lock()
|
self.maplock = Lock()
|
||||||
self.diskr2l, self.diskl2r = self._loadmaps()
|
self.diskr2l, self.diskl2r = self._loadmaps()
|
||||||
@ -94,6 +96,9 @@ class MappedIMAPFolder(IMAPFolder):
|
|||||||
return (r2l, l2r)
|
return (r2l, l2r)
|
||||||
|
|
||||||
def _savemaps(self):
|
def _savemaps(self):
|
||||||
|
if self.dryrun is True:
|
||||||
|
return
|
||||||
|
|
||||||
mapfilename = self._getmapfilename()
|
mapfilename = self._getmapfilename()
|
||||||
# Do not use the map file directly to prevent from leaving it truncated.
|
# Do not use the map file directly to prevent from leaving it truncated.
|
||||||
mapfilenametmp = "%s.tmp"% mapfilename
|
mapfilenametmp = "%s.tmp"% mapfilename
|
||||||
@ -136,7 +141,6 @@ class MappedIMAPFolder(IMAPFolder):
|
|||||||
with self.maplock:
|
with self.maplock:
|
||||||
# OK. Now we've got a nice list. First, delete things from the
|
# OK. Now we've got a nice list. First, delete things from the
|
||||||
# summary that have been deleted from the folder.
|
# summary that have been deleted from the folder.
|
||||||
|
|
||||||
for luid in self.diskl2r.keys():
|
for luid in self.diskl2r.keys():
|
||||||
if not luid in reallist:
|
if not luid in reallist:
|
||||||
ruid = self.diskl2r[luid]
|
ruid = self.diskl2r[luid]
|
||||||
|
Loading…
Reference in New Issue
Block a user