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

Function resolveOutputCommitPath

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

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

Callers 1

WriteMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected