9p: simplify BatchJobStore.Wait; remove CurrentWaitValue

State is terminal-only (running→done/failed), so base comparison
adds nothing — block on the done channel directly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Levi Neely 2026-04-20 20:06:40 +02:00
parent 4d5ae06780
commit 0e43664b40
1 changed files with 4 additions and 23 deletions

View File

@ -490,38 +490,19 @@ func (js *BatchJobStore) content(name string) string {
return ""
}
// CurrentWaitValue returns the current value for the named *wait file.
func (js *BatchJobStore) CurrentWaitValue(name string) string {
if name == "statewait" {
js.job.mu.RLock()
defer js.job.mu.RUnlock()
return js.job.state
}
return ""
}
// Wait blocks until the job leaves "running" state, then returns the new state.
// Wait blocks until the job reaches a terminal state, then returns it.
// Returns nil content (empty read) on context cancellation.
func (js *BatchJobStore) Wait(ctx context.Context, name, base string) ([]byte, error) {
func (js *BatchJobStore) Wait(ctx context.Context, name, _ string) ([]byte, error) {
if name != "statewait" {
return nil, fmt.Errorf("%s: not a wait file", name)
}
js.job.mu.RLock()
current := js.job.state
js.job.mu.RUnlock()
if base == "" {
base = current
}
if current != base {
return []byte(current + "\n"), nil
}
select {
case <-ctx.Done():
return nil, nil
case <-js.job.done:
}
js.job.mu.RLock()
current = js.job.state
state := js.job.state
js.job.mu.RUnlock()
return []byte(current + "\n"), nil
return []byte(state + "\n"), nil
}