40 lines
761 B
Go
40 lines
761 B
Go
// backend\record_job_progress.go
|
|
|
|
package main
|
|
|
|
func setJobProgress(job *RecordJob, phase string, pct int) {
|
|
if pct < 0 {
|
|
pct = 0
|
|
}
|
|
if pct > 100 {
|
|
pct = 100
|
|
}
|
|
|
|
jobsMu.Lock()
|
|
defer jobsMu.Unlock()
|
|
|
|
// ✅ Sobald Postwork/Phase läuft oder Aufnahme beendet ist:
|
|
// keine "alten" Recorder-Updates mehr akzeptieren
|
|
if job.EndedAt != nil || (job.Phase != "" && job.Phase != "recording") {
|
|
// optional: trotzdem Phase aktualisieren, aber Progress nicht senken
|
|
if phase != "" {
|
|
job.Phase = phase
|
|
}
|
|
if pct < job.Progress {
|
|
pct = job.Progress
|
|
}
|
|
job.Progress = pct
|
|
return
|
|
}
|
|
|
|
// Recording-Phase:
|
|
if phase != "" {
|
|
job.Phase = phase
|
|
}
|
|
// ✅ niemals rückwärts
|
|
if pct < job.Progress {
|
|
pct = job.Progress
|
|
}
|
|
job.Progress = pct
|
|
}
|