fix(cli): validate runtimes before uninstall

This commit is contained in:
ZacharyZhang-NY committed 2026-07-19 16:40:05 -04:00
1 parent 7bf84a35e0
commit 3488ab778c
7 files changed
+250 -87

No files matched your search

+15
View File
@@ -126,3 +126,18 @@ func RequirePhysicalDirectory(path string) (bool, error) {
}
return true, nil
}
// RequirePhysicalFile reports whether a path is an existing physical regular file.
func RequirePhysicalFile(path string) (bool, error) {
info, err := os.Lstat(path)
if os.IsNotExist(err) {
return false, nil
}
if err != nil {
return false, fmt.Errorf("inspect agent runtime file %s: %w", path, err)
}
if info.Mode()&os.ModeSymlink != 0 || !info.Mode().IsRegular() {
return false, fmt.Errorf("agent runtime config is not a physical file: %s", path)
}
return true, nil
}