[PATCH 3/5] Remove duplicated code paths

Sebastian Spaeth Sebastian at SSpaeth.de
Wed May 4 15:45:26 BST 2011


Currently, account.syncrunner() has 2 separate duplicated code paths
depending on whether we want to autorefresh after some waiting perios
or not. Unify those code paths by setting "looping = False" in case
self.refeshperiod == 0 after the first run. Behavior is identical to
before.

Signed-off-by: Sebastian Spaeth <Sebastian at SSpaeth.de>
---
 offlineimap/accounts.py |   21 ++++-----------------
 1 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/offlineimap/accounts.py b/offlineimap/accounts.py
index 7edfa37..a085288 100644
--- a/offlineimap/accounts.py
+++ b/offlineimap/accounts.py
@@ -184,22 +184,9 @@ class SyncableAccount(Account):
         self.localrepos  = Repository(self, 'local')
         self.statusrepos = Repository(self, 'status')
 
-        #might need changes here to ensure that one account sync does not crash others...
-        if not self.refreshperiod:
-            try:
-                try:
-                    self.sync(siglistener)
-                except (KeyboardInterrupt, SystemExit):
-                    raise
-                except:
-                    self.ui.warn("Error occured attempting to sync account " + self.name \
-                                 + ": " + traceback.format_exc())
-            finally:
-                self.ui.acctdone(self.name)
-
-            return
-
-
+        # Might need changes here to ensure that one account sync does
+        # not crash others...
+        # Loop account synchronization if needed
         looping = 1
         while looping:
             try:
@@ -211,7 +198,7 @@ class SyncableAccount(Account):
                     self.ui.warn("Error occured attempting to sync account " + self.name \
                                  + ": " + traceback.format_exc())
             finally:
-                looping = self.sleeper(siglistener) != 2
+                looping = self.refreshperiod and self.sleeper(siglistener) != 2
                 self.ui.acctdone(self.name)
 
 
-- 
1.7.4.1





More information about the OfflineIMAP-project mailing list