don't delete messages in local cache in dry-run mode
This makes dry-run consitent when called more than once. Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/370 Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
f634546980
commit
6b313aabd3
@ -881,8 +881,7 @@ class BaseFolder(object):
|
|||||||
self.ui.ignorecopyingmessage(uid, self, dstfolder)
|
self.ui.ignorecopyingmessage(uid, self, dstfolder)
|
||||||
|
|
||||||
if num_to_copy > 0 and self.repository.account.dryrun:
|
if num_to_copy > 0 and self.repository.account.dryrun:
|
||||||
self.ui.info(
|
self.ui.info("[DRYRUN] Copy {} messages from {}[{}] to {}".format(
|
||||||
"[DRYRUN] Copy {0} messages from {1}[{2}] to {3}".format(
|
|
||||||
num_to_copy, self, self.repository, dstfolder.repository)
|
num_to_copy, self, self.repository, dstfolder.repository)
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@ -907,11 +906,11 @@ class BaseFolder(object):
|
|||||||
# Exceptions are caught in copymessageto().
|
# Exceptions are caught in copymessageto().
|
||||||
if self.suggeststhreads():
|
if self.suggeststhreads():
|
||||||
self.waitforthread()
|
self.waitforthread()
|
||||||
thread = threadutil.InstanceLimitedThread(
|
thread=threadutil.InstanceLimitedThread(
|
||||||
self.getinstancelimitnamespace(),
|
self.getinstancelimitnamespace(),
|
||||||
target = self.copymessageto,
|
target=self.copymessageto,
|
||||||
name = "Copy message from %s:%s"% (self.repository, self),
|
name="Copy message from %s:%s"% (self.repository, self),
|
||||||
args = (uid, dstfolder, statusfolder)
|
args=(uid, dstfolder, statusfolder)
|
||||||
)
|
)
|
||||||
thread.start()
|
thread.start()
|
||||||
threads.append(thread)
|
threads.append(thread)
|
||||||
@ -947,13 +946,13 @@ class BaseFolder(object):
|
|||||||
# won't lose message, we will just unneccessarily retransmit some.
|
# won't lose message, we will just unneccessarily retransmit some.
|
||||||
# Delete messages from statusfolder that were either deleted by the
|
# Delete messages from statusfolder that were either deleted by the
|
||||||
# user, or not being tracked (e.g. because of maxage).
|
# user, or not being tracked (e.g. because of maxage).
|
||||||
|
if not self.repository.account.dryrun:
|
||||||
statusfolder.deletemessages(deletelist)
|
statusfolder.deletemessages(deletelist)
|
||||||
# Filter out untracked messages
|
# Filter out untracked messages.
|
||||||
deletelist = [uid for uid in deletelist if dstfolder.uidexists(uid)]
|
deletelist = [uid for uid in deletelist if dstfolder.uidexists(uid)]
|
||||||
if len(deletelist):
|
if len(deletelist):
|
||||||
self.ui.deletingmessages(deletelist, [dstfolder])
|
self.ui.deletingmessages(deletelist, [dstfolder])
|
||||||
if self.repository.account.dryrun:
|
if not self.repository.account.dryrun:
|
||||||
return #don't delete messages in dry-run mode
|
|
||||||
dstfolder.deletemessages(deletelist)
|
dstfolder.deletemessages(deletelist)
|
||||||
|
|
||||||
def combine_flags_and_keywords(self, uid, dstfolder):
|
def combine_flags_and_keywords(self, uid, dstfolder):
|
||||||
|
@ -24,6 +24,7 @@ import six
|
|||||||
|
|
||||||
from .Base import BaseFolder
|
from .Base import BaseFolder
|
||||||
|
|
||||||
|
|
||||||
class DatabaseFileLock(object):
|
class DatabaseFileLock(object):
|
||||||
"""Lock at database file level."""
|
"""Lock at database file level."""
|
||||||
|
|
||||||
@ -125,7 +126,7 @@ class LocalStatusSQLiteFolder(BaseFolder):
|
|||||||
self.__upgrade_db(version)
|
self.__upgrade_db(version)
|
||||||
|
|
||||||
def purge(self):
|
def purge(self):
|
||||||
"""Remove any pre-existing database."""
|
"""Remove any pre-existing database. Do not call in dry-run mode."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.unlink(self.filename)
|
os.unlink(self.filename)
|
||||||
@ -328,7 +329,7 @@ class LocalStatusSQLiteFolder(BaseFolder):
|
|||||||
# We cannot assign a uid.
|
# We cannot assign a uid.
|
||||||
return uid
|
return uid
|
||||||
|
|
||||||
if self.uidexists(uid): # already have it
|
if self.uidexists(uid): # Already have it.
|
||||||
self.savemessageflags(uid, flags)
|
self.savemessageflags(uid, flags)
|
||||||
return uid
|
return uid
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user