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

Function resolveOutputCommitPath

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

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

Callers 1

WriteMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected