MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / removeInstalledFile

Function removeInstalledFile

internal/instructions/install.go:211–229  ·  view source on GitHub ↗

removeInstalledFile deletes the installed file only when CAM can prove it owns it: a symlink pointing at managedFile, or a copy whose content still matches.

(ins Install, managedFile string)

Source from the content-addressed store, hash-verified

209// removeInstalledFile deletes the installed file only when CAM can prove it owns
210// it: a symlink pointing at managedFile, or a copy whose content still matches.
211func removeInstalledFile(ins Install, managedFile string) {
212 info, err := os.Lstat(ins.TargetPath)
213 if err != nil {
214 return
215 }
216 if info.Mode()&os.ModeSymlink != 0 {
217 if resolved, rerr := os.Readlink(ins.TargetPath); rerr == nil {
218 if filepath.Clean(resolved) == filepath.Clean(managedFile) {
219 os.Remove(ins.TargetPath)
220 }
221 }
222 return
223 }
224 if ins.LinkKind == "copy" {
225 if sameContent(ins.TargetPath, managedFile) {
226 os.Remove(ins.TargetPath)
227 }
228 }
229}
230
231func sameContent(a, b string) bool {
232 da, err := os.ReadFile(a)

Callers 2

DeleteMethod · 0.85
UninstallMethod · 0.85

Calls 2

sameContentFunction · 0.85
RemoveMethod · 0.45

Tested by

no test coverage detected