feat(02-02): add ScanWarning type and reclassify scan errors as warnings

- Add ScanWarning struct with FilePath/Phase/Err to ScanMetrics
- Add mutex-protected addWarning method for concurrent use
- Reclassify walk, extraction, commit, orphan, variant, FTS failures as warnings
- Update commitBatch to return only fatal tx.Commit errors
- Update cachedLinkArtist to check errors via database.IsUniqueViolation
- Update handleConfigUpdate to capture and log scan warning count
This commit is contained in:
2026-03-02 19:18:11 -05:00
parent 0d5b76cb0f
commit e6866ded9d
2 changed files with 83 additions and 16 deletions
+22
View File
@@ -49,6 +49,16 @@ type ScanMetrics struct {
Updated int64 `json:"updated"`
Skipped int64 `json:"skipped"`
Removed int64 `json:"removed"`
// Non-fatal issues encountered during scanning.
Warnings []ScanWarning `json:"warnings"`
}
// ScanWarning represents a non-fatal issue encountered during scanning.
type ScanWarning struct {
FilePath string `json:"filePath"`
Phase string `json:"phase"`
Err error `json:"err"`
}
func newScanMetrics() *ScanMetrics {
@@ -80,6 +90,18 @@ func (m *ScanMetrics) addCoverArtSave(d time.Duration) {
m.CoverArtSave += d
}
// addWarning records a non-fatal scan issue. Safe for concurrent use.
func (m *ScanMetrics) addWarning(filePath, phase string, err error) {
m.mu.Lock()
defer m.mu.Unlock()
m.Warnings = append(m.Warnings, ScanWarning{
FilePath: filePath,
Phase: phase,
Err: err,
})
}
// addThumbnailTier records the time spent generating a single
// thumbnail tier. Safe for concurrent use from the thumbnail
// worker pool.