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 fix 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 its metadata was last synchronized, you may want to check that the information is consistent between the various fields and tables that represent that folder's media files.

Verifying and optionally repairing folder information is often faster than resynchronizing the folder's metadata because the former doesn't entail uploading file, folder, and playlist metadata. Instead, the verification step queries the database to determine if the folders table entry is consistent with all files, folders, and playlist table entries that refer to that folder. The service logs any inconsistencies found and reports if any information can't be retrieved. The repair step updates database fields to eliminate any data inconsistencies between the related table entries; it also 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 syncpath argument and with the MMSYNC_OPTION_VERIFY flag enabled.

To do the extra step of repairing inconsistencies in 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 of its subfolders by setting the MMSYNC_OPTION_RECURSIVE flag in the command or API call.