Repairing database inconsistencies

If you find that the database information for a folder doesn't match what's actually on the mediastore at some point after you synchronized the folder, you can repair the inaccurate database content by calling mm_sync_start() or running sync_start with special parameters.

The mmsync verification and repair feature can repair inconsistencies in the database fields for a folder and for the files and playlists associated with that folder. If you're aware of many file and playlist additions, removals, or renamings in a mediastore folder since that folder was last synchronized, you may want to check that the data is consistent between the various fields and tables that represent the media files stored in that same folder on the device.

Verifying and optionally repairing folder data is often faster than resynchronizing the folder because the former doesn't entail uploading all file, folder, and playlist information for the folder being checked. Instead, the verification step queries the database to determine if the data in the folders table entry is consistent with the data in all files, folders, and playlist table entries that refer to that folder. The service logs any inconsistencies found and any information that is unable to be retrieved. The repair step updates database fields to eliminate any data inconsistencies between the related table entries and then logs this activity.

To verify the database information for a folder, look up the folder's path in the folders table, then call mm_sync_start() or run the sync_start command with this retrieved path as the path argument and with the MMSYNC_OPTION_VERIFY flag enabled.

To perform the extra step of repairing inconsistencies in the folder data, enable the MMSYNC_OPTION_REPAIR flag in addition to the verification flag. If mm-sync is unable to repair any inconsistencies, it notes the incomplete repair work in the system log. In such cases, there's probably a database problem that requires immediate attention.

Note: You can verify and repair the database information not just for one folder but for a folder and all its subfolders by setting the MMSYNC_OPTION_RECURSIVE flag in the command or API call.