Tracking synchronization progress

You can track which synchronization passes have been completed and which folders have had their metadata synchronized. This is done by reading certain database fields or retrieving the synchronization status and folder-specific events through the mm-sync API.

Tracking progress by reading database fields

During synchronization, mm-sync updates the syncflags field in the mediastore_metadata table when a pass successfully completes. This field uses separate bits to indicate which of the three passes are now complete, represented as follows:
  • The least-significant bit (bit 0) indicates whether the files pass is complete (001)
  • The next-significant bit (bit 1) indicates whether the metadata pass is complete (010)
  • The next-significant bit (bit 2) indicates whether the playlist pass is complete (100)

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

These flags aren't cleared if the mediastore is made inactive. For instance, when a disk is moved out of the active slot while in a multidisk changer, no flags are cleared in the syncflags field because the disk isn't made unavailable, only inactive.

The mm-sync service 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 metadata get synchronized. If the recursive option is set, mm-sync starts from the root folder named in the synchronization path and descends into the subfolders. This means that metadata from individual folders get synchronized at different times during each requested pass. The synced field allows client applications to know when a given folder's database information is up to date and won't change.

Tracking progress through API functions

You can call mm_sync_status_get(), mm_sync_status_get_byid(), and mm_sync_status_get_bydbname() in the mm-sync API to monitor synchronization progress. The API functions write progress information into an mmsync_status_t structure, which includes these three fields: passes_done, current_pass, and passes_to_do. Each field has the same format as the syncflags database field explained above.

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

To monitor folder synchronization, your client application can specify which folder-based events to deliver (in the mm-sync configuration file), then register for synchronization events. Using events to track progress is helpful when synchronizing a priority folder.