Skip to main content

Module sync_index

Module sync_index 

Source
Expand description

Maintains a persistent index of files that have been previously synced.

The index maps local file paths to their checksums, modification times, and target album IDs. A sharded design (ShardedSyncIndex) distributes entries across multiple segment files for lock-free concurrent reads during parallel scans. On startup, unchanged files are skipped entirely by comparing stored checksums against the current state.

Structsยง

Shard ๐Ÿ”’
A single shard of the sync index, holding a subset of entries.
ShardedSyncIndex
Thread-safe sync index that distributes entries across 16 RwLock shards keyed by path hash. This eliminates the single-lock bottleneck when parallel producers (startup scan, watcher workers) and consumers (library UI sync-state lookups) all contend on the index simultaneously.
SyncIndexData ๐Ÿ”’
Inner serialized structure representing the index files list.
SyncIndexDataRef ๐Ÿ”’
Borrowed reference of the serialized index for zero-copy writes.
SyncTarget
Describes the intended album target for a file during sync operations.
SyncedFileRecord
Represents a record stored on disk for a synced file, including the last associated album target.

Enumsยง

SyncDecision
Indicates the result of comparing a file on disk with the saved sync index.

Constantsยง

SHARD_COUNT ๐Ÿ”’
Number of shards for distributing sync index entries.

Functionsยง

fingerprint_from_metadata ๐Ÿ”’
Helper to calculate the size and modification timestamp fingerprint of a file.
load_entries ๐Ÿ”’
Helper to load all stored sync records from the file.
migrate_from_cache_dir ๐Ÿ”’
Migrate legacy cache-dir synced indices on first launch.
shard_for ๐Ÿ”’
Determine which shard index a path belongs to.