Skip to content

Local File Structure

This documentation describes the local file structure, that is written by this application. Even though the design of this application should handle alterations to the file system structure, it is not recommended to change it manually.

Design Goal

The structure was created with the primary design goal of not requiring an additional database system, that keeps track of the metadata of locally synced assets. There is a performance impact on the load time of the local library, as the full data tree has to be scanned when loading the local state, however this choice was made deliberately:

  • Reduces system complexity for handling a database system
  • Ensures that the local file system will never deviate from the metadata store
  • Never having to deal with a corrupted metadata store

This approach is trading off performance with data integrity and should ensure straight forward failure recovery.

Root folder

The root folder is specified through environment variable DATA_DIR. All assets and information are stored here:

Asset Directories

The primary and shared asset directory contain the actual assets, downloaded from the iCloud backend.

Their filename is the unique checksum, as provided by the iCloud backend, together with their correct file extension. The m-time is set, based on the returned 'modified' timestamp.

The filename was selected to use the checksum as a unique asset identifier. This allows efficient comparison of local and remote assets while avoiding naming conflicts. Additional comparison checks include the file size and the modified timestamp.

Primary Asset dir

The primary asset dir contains all assets stored in the user's iCloud Photos Library.

Shared Asset Dir

The asset dir contains all assets stored in the shared iCloud Photos Library.

Archive Dir

If an archived folder is deleted in the iCloud backend, this folder will be moved to the archive dir. When archived folders are moved on the backend, a subfolder (.stash) is used to keep track of them. Files and folders in this directory are ignored by this application and can be organized in this folder as you wish.

User Folders

Every user folder has two components:

  • A symlink with the display name of the folder/album, which links to
  • A folder containing the data, named after the UUID of the folder (and hidden: .{UUID})

This is done to keep sync relevant UUIDs within the file system, while presenting the user with readable strings that resemble their photos library.

For each asset within an album, a link to the (~~shared or~~ primary) asset dir is created. Naming is based on the filename, provided by iCloud. Original files don't have a suffix, edits are suffixed with -edited, live photos are suffixed with -live (see src).

Due to current limitations of the iCloud Web API, user folders only contain assets from the primary library, assets from the shared library cannot be linked to user folders.

If a user folder contains any file that is not defined as safe (see Safe Files), it is marked as archived, and its content is ignored upon future syncs.