refactor: update indexed_at timestamp for synchronization consistency

- Added logic to update the indexed_at timestamp in both entry and aggregation phases to ensure that changes are picked up during incremental sync.
This commit is contained in:
Jamie Pine 2025-11-16 13:30:38 -08:00
parent 93b857b3d8
commit 887c2d1c0d
2 changed files with 9 additions and 0 deletions

View File

@ -455,6 +455,11 @@ impl EntryProcessor {
entry_active.inode = Set(Some(inode as i64));
}
// TODO: Rename indexed_at to last_indexed_at to better reflect its purpose
// Update indexed_at so incremental sync picks up this change
// Without this, modified entries would be skipped by watermark-based queries
entry_active.indexed_at = Set(Some(chrono::Utc::now()));
entry_active
.update(ctx.library_db())
.await

View File

@ -134,6 +134,8 @@ pub async fn run_aggregation_phase(
active_dir.aggregate_size = Set(aggregate_size);
active_dir.child_count = Set(child_count);
active_dir.file_count = Set(file_count);
// Update indexed_at so aggregate changes are picked up by sync
active_dir.indexed_at = Set(Some(chrono::Utc::now()));
active_dir.update(ctx.library_db()).await.map_err(|e| {
JobError::execution(format!("Failed to update directory aggregates: {}", e))
@ -288,6 +290,8 @@ pub async fn migrate_directory_sizes(db: &DatabaseConnection) -> Result<(), DbEr
active_dir.aggregate_size = Set(aggregate_size);
active_dir.child_count = Set(child_count);
active_dir.file_count = Set(file_count);
// Update indexed_at so aggregate changes are picked up by sync
active_dir.indexed_at = Set(Some(chrono::Utc::now()));
active_dir.update(db).await?;
}