saveTranscriptToFile persists transcript bytes to the canonical artifact path for the given minute_token. Returns the file path on success (or when the file already exists and --overwrite is not set), empty string on any failure.
(runtime *common.RuntimeContext, minuteToken, title string, content []byte)
| 476 | // for the given minute_token. Returns the file path on success (or when the |
| 477 | // file already exists and --overwrite is not set), empty string on any failure. |
| 478 | func saveTranscriptToFile(runtime *common.RuntimeContext, minuteToken, title string, content []byte) string { |
| 479 | errOut := runtime.IO().ErrOut |
| 480 | |
| 481 | // With no --output-dir the default layout shares the directory with |
| 482 | // `minutes +download`. Legacy layout is preserved when the flag is set. |
| 483 | var dirName string |
| 484 | if outDir := runtime.Str("output-dir"); outDir != "" { |
| 485 | dirName = filepath.Join(outDir, sanitizeDirName(title, minuteToken)) |
| 486 | } else { |
| 487 | dirName = common.DefaultMinuteArtifactDir(minuteToken) |
| 488 | } |
| 489 | transcriptPath := filepath.Join(dirName, common.DefaultTranscriptFileName) |
| 490 | |
| 491 | if !runtime.Bool("overwrite") { |
| 492 | if _, statErr := runtime.FileIO().Stat(transcriptPath); statErr == nil { |
| 493 | fmt.Fprintf(errOut, "%s transcript already exists: %s (use --overwrite to replace)\n", logPrefix, transcriptPath) |
| 494 | return transcriptPath |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | fmt.Fprintf(errOut, "%s writing transcript: %s\n", logPrefix, transcriptPath) |
| 499 | if _, err := runtime.FileIO().Save(transcriptPath, fileio.SaveOptions{}, bytes.NewReader(content)); err != nil { |
| 500 | var me *fileio.MkdirError |
| 501 | switch { |
| 502 | case errors.Is(err, fileio.ErrPathValidation): |
| 503 | fmt.Fprintf(errOut, "%s invalid transcript path: %v\n", logPrefix, err) |
| 504 | case errors.As(err, &me): |
| 505 | fmt.Fprintf(errOut, "%s failed to create directory: %v\n", logPrefix, err) |
| 506 | default: |
| 507 | fmt.Fprintf(errOut, "%s failed to write transcript: %v\n", logPrefix, err) |
| 508 | } |
| 509 | return "" |
| 510 | } |
| 511 | return transcriptPath |
| 512 | } |
| 513 | |
| 514 | // fetchNoteDetail retrieves note fields via note_id by delegating to the note |
| 515 | // domain (the canonical owner of note-detail parsing) and adapting the typed |
no test coverage detected