(state *State)
| 469 | } |
| 470 | |
| 471 | func (r *Repository) writeUnlocked(state *State) error { |
| 472 | data, err := json.MarshalIndent(state, "", " ") |
| 473 | if err != nil { |
| 474 | return fmt.Errorf("encode batch: %w", err) |
| 475 | } |
| 476 | |
| 477 | data = append(data, '\n') |
| 478 | if err := r.writeFile(r.path(state.BatchID), data, 0o600); err != nil { |
| 479 | return fmt.Errorf("write batch: %w", err) |
| 480 | } |
| 481 | |
| 482 | return nil |
| 483 | } |
| 484 | |
| 485 | func (r *Repository) path(batchID string) string { |
| 486 | return filepath.Join(r.dir, batchID+".json") |
no test coverage detected