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)
| 640 | // symlink: write through the link to its target instead of replacing the link |
| 641 | // itself during the final rename. |
| 642 | func resolveOutputCommitPath(path string) (string, error) { |
| 643 | info, err := os.Lstat(path) |
| 644 | if err != nil { |
| 645 | if os.IsNotExist(err) { |
| 646 | return path, nil |
| 647 | } |
| 648 | return "", fmt.Errorf("inspect output path %s: %w", path, err) |
| 649 | } |
| 650 | if info.Mode()&os.ModeSymlink == 0 { |
| 651 | return path, nil |
| 652 | } |
| 653 | resolved, err := filepath.EvalSymlinks(path) |
| 654 | if err != nil { |
| 655 | return "", fmt.Errorf("resolve output symlink %s: %w", path, err) |
| 656 | } |
| 657 | return resolved, nil |
| 658 | } |
| 659 | |
| 660 | func cleanupOutputTemp(file *os.File, path string) error { |
| 661 | var cleanupErr error |