Tracking synchronization progress

You can track synchronization progress in terms of what passes have been completed for a mediastore by reading the syncflags database field or by retrieving the synchronization status through the mm-sync API.

The mm-sync service updates the syncflags field in the mediastore_metadata table when a synchronization pass successfully completes. The syncflags field uses separate bits to indicate which of the three passes are complete, represented as follows:

For example, a value of 0 in syncflags means that no synchronization passes have been completed; a value of 5 (101) means that the file and playlist passes have been completed, but the metadata pass was skipped. A value of 7 (111) indicates that all three synchronization passes have been completed.

These flags are not cleared if the device is made inactive. When a disk is moved out of the active slot while in a multidisk changer, the disk is not made unavailable, only inactive. Therefore, this action doesn't clear any existing synchronization flags in the syncflags field.

API functions for retrieving synchronization status

You can call the mm_sync_status_get(), mm_sync_status_get_byid(), and mm_sync_status_get_bydbname() API functions to monitor synchronization progress. The mm-sync API stores synchronization progress information in the mmsync_status_t data type, with three fields: passes_done, current_pass, and passes_to_do. These fields have the same format as the syncflags database field.

Suppose you start a synchronization and request all three passes, and then cancel the operation just as the files pass is successfully completing. If you then get the synchronization status through the API, the passes_done value is 1 (001), the current_pass value is 0 (000), and the passes_to_do value is 6 (110). These values show that only the first pass was done and that no pass is in progress.

Tracking folder synchronizations

The mm-sync process also marks synchronization progress at the folder level by updating the synced field in the folders table entry for a specific folder as soon as its contents have been synchronized. When the recursive option is set, mm-sync starts from the folder named in the path and descends into the subfolders, meaning individual folders get synchronized at different times during each requested pass. The synced field allows client applications to know when a given folder has been synchronized, which means its database information will not change.

An alternative to polling the synced field is for your client application to register for synchronization events and specify, in the configuration file, which optional folder-based synchronization events to deliver. Tracking progress through folder events is helpful when synchronizing a priority folder.