fix(02): write fixtures exclusively and only on successful flush (WR-01)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jakub Zych
2026-09-17 14:41:18 +02:00
parent 5994e671b3
commit 7e70afe819
5 changed files with 92 additions and 9 deletions

View File

@@ -336,7 +336,10 @@ func recordSeed(ctx context.Context, seed *Seed, cfg ManifestConfig) error {
if err != nil {
return err
}
return SaveFlow(dest, flow)
if _, err := os.Stat(dest); err == nil {
return SaveFlow(dest, flow)
}
return SaveFlowExclusive(dest, flow)
}
func seedAlreadyRecorded(path string) (bool, error) {
@@ -404,7 +407,13 @@ func recordRoute(ctx context.Context, route Route, cfg ManifestConfig) error {
if err != nil {
return err
}
if err := SaveFlow(dest, flow); err != nil {
if cfg.Update {
if err := SaveFlow(dest, flow); err != nil {
return err
}
continue
}
if err := SaveFlowExclusive(dest, flow); err != nil {
return err
}
}