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

Function resolveOutputCommitPath

cmd/opencodereview/shared.go:565–581  ·  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

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

Callers 1

WriteMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected