diff --git a/src/core/db/postgres_db.rs b/src/core/db/postgres_db.rs index 0a7321e7..198d4ec9 100644 --- a/src/core/db/postgres_db.rs +++ b/src/core/db/postgres_db.rs @@ -2395,6 +2395,10 @@ impl PostgresDb { r#" INSERT INTO {} (uuid, video_path, status, video_id, processors, face_settings) VALUES ($1, $2, 'pending', $3, {}::text[], $4::jsonb) + ON CONFLICT (uuid) DO UPDATE SET + status = 'pending', video_path = EXCLUDED.video_path, + video_id = EXCLUDED.video_id, processors = EXCLUDED.processors, + face_settings = EXCLUDED.face_settings, updated_at = NOW() RETURNING id, uuid, video_path, status, current_processor, progress_total, progress_current, error_count, last_error, started_at::TEXT, updated_at::TEXT, created_at::TEXT, processors, completed_processors, failed_processors, video_id, face_settings::text "#, jobs_table, processors_array diff --git a/src/worker/job_worker.rs b/src/worker/job_worker.rs index e2a48549..581b383a 100644 --- a/src/worker/job_worker.rs +++ b/src/worker/job_worker.rs @@ -346,7 +346,8 @@ impl JobWorker { FROM {v_t} v WHERE v.status = 'pending' AND v.file_type IN ('video', 'mp4', 'mov', 'avi', 'mkv') - AND NOT EXISTS (SELECT 1 FROM {mj_t} mj WHERE mj.uuid = v.file_uuid)", + AND NOT EXISTS (SELECT 1 FROM {mj_t} mj WHERE mj.uuid = v.file_uuid) + ON CONFLICT (uuid) DO NOTHING", mj_t = monitor_jobs_table, v_t = videos_table ))