Drop all connections when a sync failed

in accounts.sync() we would holdordropconnections() after each sync. But
depending on the repository configuration that might imply that
offlineimap tries to keep the same connections. But when a sync failed,
e.g. after a user had his computer suspended, it might be that our
connections that we have are worthless. So definitely drop them after a
failed sync.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Sebastian Spaeth 2011-04-27 11:44:24 +02:00 committed by Nicolas Sebrecht
parent 0bc1c9583e
commit 163f1eefc4
2 changed files with 11 additions and 1 deletions

View File

@ -23,6 +23,9 @@ Changes
Bug Fixes
---------
* Drop connection if synchronisation failed. This is needed if resuming the
system from suspend mode gives a wrong connection.
Pending for the next major release
==================================

View File

@ -268,7 +268,14 @@ class SyncableAccount(Account):
mbnames.write()
localrepos.forgetfolders()
remoterepos.forgetfolders()
finally:
except:
#error while syncing. Drop all connections that we have, they
#might be bogus by now (e.g. after suspend)
localrepos.dropconnections()
remoterepos.dropconnections()
raise
else:
# sync went fine. Hold or drop depending on config
localrepos.holdordropconnections()
remoterepos.holdordropconnections()