fix: startup crash, watcher count, timeline date fallback
db.rs: - Move idx_images_taken_at creation to after ensure_column so it never runs against a schema where taken_at doesn't exist yet; this was causing a startup panic on any DB that predates Phase 1 - COALESCE(taken_at, created_at) → COALESCE(taken_at, modified_at) since created_at is never populated (modified_at is always set) - Remove dead is_tagging_job_cancelled function (superseded by is_tagging_job_processing) and unused thumbnail_path from ImagePathRecord indexer.rs: - Watcher create path now calls update_folder_count after commit_batch and emits folder-counts-changed so the sidebar count stays in sync; the notification is only emitted when the DB write actually succeeds store.ts / Timeline.tsx: - compareImages taken_asc/taken_desc: fall back to modified_at not created_at (created_at is always null) - Timeline groupImages: same fallback fix so images group by month correctly for libraries not yet re-indexed for EXIF - subscribeToProgress: listen for folder-counts-changed and call loadFolders() to keep the sidebar image count live
This commit is contained in:
@@ -1480,8 +1480,17 @@ fn process_watcher_path(
|
||||
|
||||
match commit_batch(pool, &[record]) {
|
||||
Ok(committed) if !committed.is_empty() => {
|
||||
// Always emit the images — they are committed to the DB.
|
||||
emit_images(app, &IndexedImagesBatch { folder_id, images: committed });
|
||||
emit_folder_job_progress(app, pool, &[folder_id], false);
|
||||
// Update the sidebar count only if we successfully write the new
|
||||
// count; skip the frontend notification on pool/DB failure to
|
||||
// avoid showing a stale number.
|
||||
if let Ok(count_conn) = pool.get() {
|
||||
if db::update_folder_count(&count_conn, folder_id).is_ok() {
|
||||
let _ = app.emit("folder-counts-changed", ());
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(_) => {}
|
||||
Err(e) => eprintln!("Watcher: commit error for {:?}: {}", path, e),
|
||||
@@ -1494,6 +1503,7 @@ fn process_watcher_path(
|
||||
if db::delete_images_by_ids(&conn, &[image_id]).is_ok() {
|
||||
db::update_folder_count(&conn, folder_id).ok();
|
||||
let _ = app.emit("watcher-deleted", vec![image_id]);
|
||||
let _ = app.emit("folder-counts-changed", ());
|
||||
}
|
||||
}
|
||||
Ok(None) => {} // never indexed or already removed
|
||||
|
||||
Reference in New Issue
Block a user