undo whitespace change, add comments

This commit is contained in:
silverwind
2026-02-19 04:14:40 +01:00
parent 3e139b7f09
commit c1c36d1c2d

View File

@@ -25,8 +25,7 @@ type Reporter struct {
ctx context.Context ctx context.Context
cancel context.CancelFunc cancel context.CancelFunc
closed bool closed bool
client client.Client client client.Client
clientM sync.Mutex clientM sync.Mutex
@@ -300,7 +299,8 @@ func (r *Reporter) ReportLog(noMore bool) error {
return nil return nil
} }
// ReportState reports the current task state unless the reporter is closed. // ReportState skips when closed so RunDaemon cannot send a completed state
// before Close sends the final logs.
func (r *Reporter) ReportState() error { func (r *Reporter) ReportState() error {
r.stateMu.RLock() r.stateMu.RLock()
closed := r.closed closed := r.closed
@@ -311,6 +311,7 @@ func (r *Reporter) ReportState() error {
return r.reportState() return r.reportState()
} }
// reportState sends unconditionally. Used by Close after final logs are uploaded.
func (r *Reporter) reportState() error { func (r *Reporter) reportState() error {
r.clientM.Lock() r.clientM.Lock()
defer r.clientM.Unlock() defer r.clientM.Unlock()