Mediastore filesystem traversal

At each pass, mm-sync traverses the mediastore filesystem to extract and upload metadata into the database. The synchronization path determines which section of the filesystem tree gets synchronized. If a blank path is given and the recursive option is set, the entire filesystem gets synchronized. Otherwise, only the files and folders within the named path get synchronized.

The filesystem is traversed with a breadth-first walk of the mediastore's directory structure, as follows:
  1. The mm-sync service starts at the root node within the synchronization path. When a blank path is given, the root is the mediastore's root folder. The root object is synchronized before any others.
  2. Root objects that are folders can contain other objects, either files or subfolders. The service synchronizes any objects in the root before examining the contents of any of those objects.
  3. If the recursive option is set, for every contained object that is a folder, mm-sync traverses that object's directory structure to synchronize its contents before starting on the next folder.
The following image shows the synchronization order for typical contents of a mediastore filesystem:

You can enable or disable the recursive option (MMSYNC_OPTION_RECURSIVE) in the call to mm_sync_start() or in the sync_start command. By default, this option is disabled, so you must enable it when you want to synchronize the entire mediastore or a whole directory subtree.

This traversal policy ensures that all folders with the same parent node are synchronized before folders deeper in the tree are examined. So, mm-sync will display information about the contents in the root folder before it retrieves information about files in subfolders. This progressive information retrieval makes sense because end users often start at the filesystem root when they first access mediastores, and then descend into subfolders as they explore the media content.

Note: If you cancel a synchronization in progress, some folders may be fully synchronized while others may not have any of their contents synchronized.

The synchronization path provided by the client to mm-sync determines the synchronization startpoint (the root node in the walk). This path is relative to the mediastore filesystem. For example, the path The_Doors tells mm-sync to locate the object named The_Doors within the root folder. If the name refers to a file, only that file gets synchronized. If the name refers to a folder, the files it contains get synchronized; when the recursive option has been set, the subfolders also get synchronized.