Mediastore filesystem traversal

At each synchronization pass, mm-sync traverses the mediastore filesystem to extract and upload media information into the mediastore's database. The section of the filesystem tree that is synchronized depends on the user-specified path. If a blank path is given and the recursive option is set, the entire filesystem is synchronized. Otherwise, only the files and folders named by the path are synchronized.

The filesystem traversal is done with a breadth-first walk of the mediastore's directory structure, as follows:

  1. Start at the root node of the section of the filesystem tree being synchronized. When a blank path is given, the root is the mediastore's root folder. Synchronize this root object before any others.
  2. Root objects that are folders can contain other objects, which may be files or subfolders. Synchronize 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, traverse its 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 remember to set the flag when you want to synchronize the entire mediastore or a whole subtree of its directory structure.

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 on the contents in the root folder before it retrieves information on 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). The 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.