From 2542224d7b263f16ec6e077d031606d26b64d53b Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Tue, 21 Feb 2023 11:47:11 +0200 Subject: [PATCH] Skip paths with errors in chmod hook Signed-off-by: Evan Lezar --- cmd/nvidia-ctk/hook/chmod/chmod.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/nvidia-ctk/hook/chmod/chmod.go b/cmd/nvidia-ctk/hook/chmod/chmod.go index cad6edfa..0a78b6e8 100644 --- a/cmd/nvidia-ctk/hook/chmod/chmod.go +++ b/cmd/nvidia-ctk/hook/chmod/chmod.go @@ -18,6 +18,7 @@ package chmod import ( "fmt" + "os" "path/filepath" "strings" "syscall" @@ -133,7 +134,12 @@ func (m command) run(c *cli.Context, cfg *config) error { func (m command) getPaths(root string, paths []string) []string { var pathsInRoot []string for _, f := range paths { - pathsInRoot = append(pathsInRoot, filepath.Join(root, f)) + path := filepath.Join(root, f) + if _, err := os.Stat(path); err != nil { + m.logger.Debugf("Skipping path %q: %v", path, err) + continue + } + pathsInRoot = append(pathsInRoot, path) } return pathsInRoot