docker-offlineimap/offlineimap
Sebastian Spaeth 3eee821382 Simplify the syncing strategy a bit
The previous syncing strategy was doing more than we needed to and was a
bit underdocumented. This is an attempt to clean it up.

1) Do away with the previous different code paths depending on
whether there is a LocalStatus file or not (the isnewfolder() test). We
always use the same strategy now, which makes the strategy easier to
understand. This strategy is simply:

a) Sync remote to local folder first
b) Sync local to remote

Where each sync implies a 4 pass strategy which does basically the same
as before (explained below).

2) Don't delete messages on LOCAL which don't exist on REMOTE right at
the beginning anymore. This prevented us e.g. from keeping local
messages rather than redownloading everything once LocalStatus got
corrupted or deleted. This surprised many who put in an existing local
maildir and expected it to be synced to the remote place. Instead, the
local maildir was deleted. This is a data loss that actually occured to
people!

3) No need to separately sync the statusfolder, we update that one
simultanously with the destfolders...

3) Simplified the sync function API by only taking one destdir rather
than a list of destdirs, we never used more anyway. This makes the code
easier to read.

4) Added plenty of code comments while I was going through to make sure
the strategy is easy to understand.
-----------------------------------------

 Pass1: Transfer new local messages
        Upload msg with negative/no UIDs to dstfolder. dstfolder should
        assign that message a new UID. Update statusfolder.

 Pass2: Copy existing messages
        Copy messages in self, but not statusfolder to dstfolder if not
        already in dstfolder. Update statusfolder.

 Pass3: Remove deleted messages
        Get all UIDS in statusfolder but not self. These are messages
        that we have locally deleted. Delete those from dstfolder and
        statusfolder.

 Pass4: Synchronize flag changes
        Compare flags in self with those in statusfolder. If msg has a
        valid UID and exists on dstfolder (has not e.g.  been deleted
        there), sync the flag change to dstfolder and statusfolder.

The user visible implications of this change should be unnoticable
except in one situation:
 Blowing away LocalStatus will not require you to redownload ALL of
 your mails if you still have the local Maildir. It will simply recreate
 LocalStatus.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2011-03-07 21:11:10 +01:00
..
folder Simplify the syncing strategy a bit 2011-03-07 21:11:10 +01:00
repository Merge branch 'ss/debug-folderfilter' into next 2011-03-03 19:07:35 +01:00
ui Allow to use nicer UI names 2011-03-06 15:33:29 +01:00
__init__.py v6.3.2 2011-02-21 12:26:48 +01:00
accounts.py Simplify the syncing strategy a bit 2011-03-07 21:11:10 +01:00
CustomConfig.py Improve CustomConfig documentation 2011-01-20 19:46:01 +01:00
imaplibutil.py Allow SSL connections to send keep-alive messages 2011-03-01 18:55:29 +01:00
imapserver.py Merge branch 'ss/remove-uneeded-darwin-workaround' into next 2011-03-05 16:37:35 +01:00
imaputil.py Remove over-verbose debug options 2011-03-03 18:23:32 +01:00
init.py Merge branch 'ss/deprecate-current-ui-names' into next 2011-03-06 18:33:29 +01:00
localeval.py Update FSF address 2006-08-12 05:15:55 +01:00
mbnames.py Update FSF address 2006-08-12 05:15:55 +01:00
syncmaster.py Implement true single-threading 2011-01-14 19:25:11 +01:00
threadutil.py Remove MultiLock implementation 2011-01-25 19:19:14 +01:00