Files
felhom-controller/controller/cmd/controller/run_record_wiring.go
T

34 lines
1.2 KiB
Go

package main
import (
"log"
"path/filepath"
"time"
"gitea.dooplex.hu/admin/felhom-controller/internal/backup"
)
// R-519 (v0.296.0) — an app-data backup run cut off by a power cut or a restart is said on the backup pages until
// the next complete run (internal/backup/run_record.go). main() calls this right after the restore record, before
// any page or any backup run can read the manager. Pinned by TestMainWiresRunRecord.
// runRecordFileName lives in DataDir, beside settings.json and the restore record.
const runRecordFileName = "appdata-run.json"
func loadRunRecordAtStartup(mgr *backup.Manager, dataDir string, logger *log.Logger) time.Time {
if mgr == nil {
return time.Time{}
}
path := filepath.Join(dataDir, runRecordFileName)
mgr.SetRunRecordPath(path)
cut := mgr.LoadRunRecord()
if logger != nil {
if !cut.IsZero() {
logger.Printf("[WARN] [backup] the app-data backup run started %s was cut off by the stop — the backup pages say so until the next complete run (R-519)", cut.UTC().Format(time.RFC3339))
} else {
logger.Printf("[INFO] [backup] app-data run record wired: %s (an earlier cut still shown: %t)", path, !mgr.InterruptedRunAt().IsZero())
}
}
return cut
}