From 30c2b0fe8232cc748ab2bded6ab4d76febe32425 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 3 May 2026 19:17:04 +0300 Subject: fix(admin): fix rescan goroutine lifecycle and race on shared ScanProgress - Protect adminService scan state (cancel func + progress pointer) with sync.Mutex. - Allocate fresh ScanProgress per trigger and pass it to the scanner, eliminating races on the previously shared progress struct. - Cancel previous scan context before starting a new one. - Add tests for cancellation, fresh progress per scan, concurrent triggers, and empty progress when never started. - Fix race-prone tests by polling Running==true before waiting for completion. --- internal/repository/migrate.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'internal/repository/migrate.go') diff --git a/internal/repository/migrate.go b/internal/repository/migrate.go index 60cea03..3c1e8bb 100644 --- a/internal/repository/migrate.go +++ b/internal/repository/migrate.go @@ -42,12 +42,21 @@ CREATE TABLE IF NOT EXISTS media ( rel_path TEXT NOT NULL, file_name TEXT NOT NULL, abs_path TEXT NOT NULL, - type TEXT CHECK(type IN ('video','audio')) NOT NULL, + type TEXT CHECK(type IN ('video','audio','image')) NOT NULL, duration REAL, codec TEXT, resolution TEXT, bitrate INTEGER, file_size_bytes INTEGER, + width INTEGER, + height INTEGER, + exif_camera TEXT, + exif_lens TEXT, + exif_date TEXT, + exif_iso TEXT, + exif_f_number TEXT, + exif_exposure TEXT, + exif_focal_length TEXT, thumbnail_path TEXT, play_count INTEGER NOT NULL DEFAULT 0, deleted_at DATETIME, -- cgit v1.2.3