]> code.delx.au - offlineimap/commitdiff
Bug#502779: Sync accounts in order of general.accounts option
authorJonny Lamb <jonny@debian.org>
Tue, 5 May 2009 19:47:11 +0000 (20:47 +0100)
committerJohn Goerzen <jgoerzen@complete.org>
Tue, 5 May 2009 20:16:25 +0000 (15:16 -0500)
On Tue, Apr 21, 11:19:00 -0500, John Goerzen wrote:
> I think the one loss of functionality we have here is that it doesn't
> check if a given account has already been listed before adding to the
> list.  Should be a simple tweak.  If you could tweak that and test, I'd
> apply a new patch.

Good catch. I attach an updated patch which I've tested and it appears
to work fine, including not syncing two accounts twice.

Thanks,

--
Jonny Lamb, UK
jonny@debian.org

From 7f348ee116bba64f7330e28d4e7b2c015910a890 Mon Sep 17 00:00:00 2001
From: Jonny Lamb <jonny@debian.org>
Date: Tue, 05 May 2009 20:45:17 +0100
Subject: [PATCH] Respect order of general.accounts config setting.

This makes the order of account synchronisation the same as the order of
the general.accounts setting by using a list instead of a dict, which
was actually pointless as the value of each dict item was never even
looked at.

Signed-off-by: Jonny Lamb <jonny@debian.org>
offlineimap/init.py

index 526478c86c91106676ffb5da3c145dcf55901a21..8d888b43d8c0884d80ef22da728be215f065edeb 100644 (file)
@@ -158,7 +158,7 @@ def startup(versionno):
         activeaccounts = activeaccounts.split(",")
         allaccounts = accounts.AccountHashGenerator(config)
 
         activeaccounts = activeaccounts.split(",")
         allaccounts = accounts.AccountHashGenerator(config)
 
-        syncaccounts = {}
+        syncaccounts = []
         for account in activeaccounts:
             if account not in allaccounts:
                 if len(allaccounts) == 0:
         for account in activeaccounts:
             if account not in allaccounts:
                 if len(allaccounts) == 0:
@@ -168,7 +168,8 @@ def startup(versionno):
                     for name in allaccounts.keys():
                         errormsg += '\n%s'%name
                 ui.terminate(1, errortitle = 'Unknown Account "%s"'%account, errormsg = errormsg)
                     for name in allaccounts.keys():
                         errormsg += '\n%s'%name
                 ui.terminate(1, errortitle = 'Unknown Account "%s"'%account, errormsg = errormsg)
-            syncaccounts[account] = allaccounts[account]
+            if account not in syncaccounts:
+                syncaccounts.append(account)
 
         server = None
         remoterepos = None
 
         server = None
         remoterepos = None