P2R-02: UI rewire against the slim-schedule + source-group model #2
@@ -74,19 +74,26 @@ func (r *Runner) RunBackup(ctx context.Context, jobID string, paths, excludes, t
|
|||||||
lastProgress := time.Now()
|
lastProgress := time.Now()
|
||||||
|
|
||||||
handle := func(stream string, line string, ev any) {
|
handle := func(stream string, line string, ev any) {
|
||||||
// Forward every line to the server as log.stream.
|
// Throttled progress events come from restic's `status` JSON.
|
||||||
now := time.Now().UTC()
|
// We deliberately do NOT forward the raw status line to
|
||||||
logEnv, _ := api.Marshal(api.MsgLogStream, "", api.LogStreamLine{
|
// log.stream — it's emitted ~every 16ms by restic --json and
|
||||||
JobID: jobID,
|
// would drown the live log in dupes for any short backup. The
|
||||||
Seq: seq.Add(1),
|
// progress widget already covers the same information at a
|
||||||
TS: now,
|
// sane sample rate.
|
||||||
Stream: api.LogStream(stream),
|
status, isStatus := ev.(restic.BackupStatus)
|
||||||
Payload: line,
|
if !isStatus {
|
||||||
})
|
now := time.Now().UTC()
|
||||||
_ = r.tx.Send(logEnv)
|
logEnv, _ := api.Marshal(api.MsgLogStream, "", api.LogStreamLine{
|
||||||
|
JobID: jobID,
|
||||||
|
Seq: seq.Add(1),
|
||||||
|
TS: now,
|
||||||
|
Stream: api.LogStream(stream),
|
||||||
|
Payload: line,
|
||||||
|
})
|
||||||
|
_ = r.tx.Send(logEnv)
|
||||||
|
}
|
||||||
|
|
||||||
// Throttled progress events.
|
if isStatus {
|
||||||
if status, ok := ev.(restic.BackupStatus); ok {
|
|
||||||
if time.Since(lastProgress) < r.progressMinPeriod {
|
if time.Since(lastProgress) < r.progressMinPeriod {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user