pub struct ShardedSyncIndex {
index_file: PathBuf,
shards: [RwLock<Shard>; 16],
}Expand description
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.
The public API is identical to the old SyncIndex but methods are inherent
– callers no longer wrap this in Arc<Mutex<_>>.
Fields§
§index_file: PathBufAbsolute path of index JSON on disk.
shards: [RwLock<Shard>; 16]Array of RwLock-wrapped entry shards.
Implementations§
Source§impl ShardedSyncIndex
impl ShardedSyncIndex
Sourcepub fn sync_decision(
&self,
path: &Path,
target: &SyncTarget,
) -> Result<SyncDecision>
pub fn sync_decision( &self, path: &Path, target: &SyncTarget, ) -> Result<SyncDecision>
Decide whether a file is already current, needs a new upload, or only needs reassociation.
Sourcepub fn record_synced(
&self,
path: &str,
checksum: &str,
target: &SyncTarget,
) -> Result<()>
pub fn record_synced( &self, path: &str, checksum: &str, target: &SyncTarget, ) -> Result<()>
Save the latest synced fingerprint and album target for a file.
Sourcepub fn prune_missing(&self, seen_paths: &HashSet<String>) -> Result<()>
pub fn prune_missing(&self, seen_paths: &HashSet<String>) -> Result<()>
Drop records for files that no longer exist under any configured watch path.
Sourcepub fn stored_checksum(&self, path: &str) -> Option<String>
pub fn stored_checksum(&self, path: &str) -> Option<String>
Reuse the previous checksum when a file only needs album reassociation.
Sourcepub fn fresh_checksum(&self, path: &Path) -> Option<String>
pub fn fresh_checksum(&self, path: &Path) -> Option<String>
Return the cached checksum only if the file’s current size + mtime still
match the stored fingerprint. Returns None when the file is missing,
untracked, or has been modified since the last index update — callers
must re-hash in that case.
Sourcepub fn record_for_path(&self, path: &str) -> Option<SyncedFileRecord>
pub fn record_for_path(&self, path: &str) -> Option<SyncedFileRecord>
Return a synced record for a specific path without touching the filesystem.
Sourcepub fn remove_path(&self, path: &str) -> Result<bool>
pub fn remove_path(&self, path: &str) -> Result<bool>
Remove one synced path from the index after a deliberate delete sync.
Sourcepub fn records_under_path(&self, root: &Path) -> Vec<(String, SyncedFileRecord)>
pub fn records_under_path(&self, root: &Path) -> Vec<(String, SyncedFileRecord)>
Return synced records rooted under a watch path.
Sourcepub fn paths_for_checksum(&self, checksum: &str) -> Vec<String>
pub fn paths_for_checksum(&self, checksum: &str) -> Vec<String>
All synced paths that share a checksum. Used to detect when an asset is referenced from more than one watch folder before trashing it.
Sourcepub fn local_path_for_checksum(&self, checksum: &str) -> Option<String>
pub fn local_path_for_checksum(&self, checksum: &str) -> Option<String>
Reverse-lookup a local path by checksum for library sync-state indicators.
Auto Trait Implementations§
impl !Freeze for ShardedSyncIndex
impl RefUnwindSafe for ShardedSyncIndex
impl Send for ShardedSyncIndex
impl Sync for ShardedSyncIndex
impl Unpin for ShardedSyncIndex
impl UnsafeUnpin for ShardedSyncIndex
impl UnwindSafe for ShardedSyncIndex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more