resolveOutputCommitPath preserves os.Create's behavior for an existing symlink: write through the link to its target instead of replacing the link itself during the final rename.
(path string)
| 558 | // symlink: write through the link to its target instead of replacing the link |
| 559 | // itself during the final rename. |
| 560 | func resolveOutputCommitPath(path string) (string, error) { |
| 561 | info, err := os.Lstat(path) |
| 562 | if err != nil { |
| 563 | if os.IsNotExist(err) { |
| 564 | return path, nil |
| 565 | } |
| 566 | return "", fmt.Errorf("inspect output path %s: %w", path, err) |
| 567 | } |
| 568 | if info.Mode()&os.ModeSymlink == 0 { |
| 569 | return path, nil |
| 570 | } |
| 571 | resolved, err := filepath.EvalSymlinks(path) |
| 572 | if err != nil { |
| 573 | return "", fmt.Errorf("resolve output symlink %s: %w", path, err) |
| 574 | } |
| 575 | return resolved, nil |
| 576 | } |
| 577 | |
| 578 | func cleanupOutputTemp(file *os.File, path string) error { |
| 579 | var cleanupErr error |