-
Notifications
You must be signed in to change notification settings - Fork 3
Synchronization process
A core functionality of the IMAP Client is its offline capability. This results in synchronization requirements at the moment when an offline account is reconnected to the IMAP server. To enable consistent synchronization behavior when changes are made to the representations, we - the Team 2022 - have rebuilt this process. Currently there are three representations of an email account. To enable smooth synchronization, we prioritized the 3 representations. Changes in a representation with more important priority will be prioritized. The prioritization is:
- IMAP server
- hard disk
- squeak image
The Squeak representation should be an image of the hard disk. To make changes to an email account, the files on the disk are modified and then synchronized so that the image matches the disk again (see 'ICFileReadWriter>>syncFromDisk'). To enable move-operations it is important that each email has a unique identifier. The UID, which comes from the IMAP protocol, is not suitable for this, because it only guarantees uniqueness within a folder. Because of this we have added the id attribute.
For performance increase it is also possible to do only partial synchronizations (see ICFileReadWriter>>sync:). All changed data must occur in the synchronization process, otherwise inconsistencies can arise
Before a synchronization starts, all IMAP commands from the ICCommandStorage are sent to the server. Then a representation of the IMAP server is fetched, this is written to disk. Care must be taken that existing references (in the squeak image) to emails are not lost. All other emails, which are not in the IMAP representation, will be deleted. (see ICFolder>>fetchEmailsWithLoadedEmails:)
Since it is uncertain which changes from the ICCommandStorage have already been processed on the server, ICFileCommandStorage is used to re-execute all local changes between the last synchronization and this one. Finally, the Squeak image will be synchronized to disk again (See ICFolder>>startUpdateWithLoadedEmails: anOrderedCollection showProgress: aBoolean with: aBlock except: aFolderCollection).