fix: backup validation display and debug logging
- Add 4-branch template guard to handle zero-value DumpValidation (shows "–" instead of misleading "Hiba" when validation never ran) - Add debug logging to ValidateDump for all code paths - Add cross-check re-validation in RefreshCache to heal stale lastDBDump validation state from disk Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -420,7 +421,8 @@ func (m *Manager) RefreshCache(nextDBDump, nextBackup time.Time) {
|
||||
if stats, err := m.restic.Stats(); err == nil {
|
||||
status.RepoStats = stats
|
||||
}
|
||||
if files, err := ListDumpFiles(m.cfg.Paths.DBDumpDir); err == nil {
|
||||
files, filesErr := ListDumpFiles(m.cfg.Paths.DBDumpDir)
|
||||
if filesErr == nil {
|
||||
status.DumpFiles = files
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
@@ -429,6 +431,25 @@ func (m *Manager) RefreshCache(nextDBDump, nextBackup time.Time) {
|
||||
status.DiscoveredDBs = dbs
|
||||
}
|
||||
|
||||
// Cross-check: if LastDBDump results have empty validation but files exist,
|
||||
// re-validate from disk. This handles controller restarts and race conditions.
|
||||
if m.lastDBDump != nil && filesErr == nil {
|
||||
fileValidation := make(map[string]DumpValidation) // keyed by filename
|
||||
for _, f := range files {
|
||||
fileValidation[f.FileName] = f.Validation
|
||||
}
|
||||
for i, r := range m.lastDBDump.Results {
|
||||
if !r.Validation.Valid && r.Validation.Error == "" && r.FilePath != "" {
|
||||
filename := filepath.Base(r.FilePath)
|
||||
if fv, ok := fileValidation[filename]; ok {
|
||||
m.lastDBDump.Results[i].Validation = fv
|
||||
m.logger.Printf("[INFO] Re-validated %s from disk: valid=%v tables=%d",
|
||||
filename, fv.Valid, fv.TableCount)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fill in dynamic fields under lock
|
||||
m.mu.Lock()
|
||||
status.Running = m.running
|
||||
|
||||
Reference in New Issue
Block a user