MCPcopy Index your code
hub / github.com/celer-pkg/celer / ensureFileReleased

Method ensureFileReleased

completion/powershell.go:125–140  ·  view source on GitHub ↗

Ensure the file is released helper method.

(filePath string)

Source from the content-addressed store, hash-verified

123
124// Ensure the file is released helper method.
125func (p powershell) ensureFileReleased(filePath string) error {
126 // Try to open the file multiple times to ensure it's released.
127 for range 3 {
128 file, err := os.OpenFile(filePath, os.O_RDONLY, 0644)
129 if err != nil {
130 // If the file cannot be opened, it may not exist or there may be other errors.
131 if os.IsNotExist(err) {
132 return fmt.Errorf("file does not exist: %s", filePath)
133 }
134 continue // Other errors, keep retrying
135 }
136 file.Close()
137 return nil // If the file can be opened and closed, it means it's released.
138 }
139 return fmt.Errorf("file is still locked after multiple attempts: %s", filePath)
140}
141
142func (p powershell) uninstallCompletion() error {
143 // Unregister completion ps file.

Callers 1

installCompletionMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected