@@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
@@ -25,6 +26,15 @@ func Open(dir string, maxRuns int) (*Store, error) {
|
||||
return nil, err
|
||||
}
|
||||
s := &Store{path: filepath.Join(dir, "runs.jsonl"), processed: map[string]struct{}{}, maxRuns: maxRuns}
|
||||
// Fail fast during startup if the persistent data path is not writable.
|
||||
// A read-only/root-owned Docker volume must not be discovered only after the first ticket.
|
||||
f, err := os.OpenFile(s.path, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o640)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("state directory %q is not writable: %w", dir, err)
|
||||
}
|
||||
if err := f.Close(); err != nil {
|
||||
return nil, fmt.Errorf("close state write probe: %w", err)
|
||||
}
|
||||
if err := s.load(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user