MCPcopy Create free account
hub / github.com/alibaba/open-code-review / resolveOutputCommitPath

Function resolveOutputCommitPath

cmd/opencodereview/shared.go:642–658  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

640// symlink: write through the link to its target instead of replacing the link
641// itself during the final rename.
642func 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
660func cleanupOutputTemp(file *os.File, path string) error {
661 var cleanupErr error

Callers 1

WriteMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected