Skip to content

Commit 7cb02c8

Browse files
only attempt to chownr the directory if it exists
1 parent f4bd75a commit 7cb02c8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

utils/perms/chmod.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
package perms
55

66
import (
7+
"errors"
78
"os"
89
"path/filepath"
910
)
1011

1112
// ChmodR sets the permissions of all directories and optionally files to [perm]
1213
// permissions.
1314
func ChmodR(dir string, dirOnly bool, perm os.FileMode) error {
15+
if _, err := os.Stat(dir); errors.Is(err, os.ErrNotExist) {
16+
return nil
17+
}
1418
return filepath.Walk(dir, func(name string, info os.FileInfo, err error) error {
1519
if err != nil || (dirOnly && !info.IsDir()) {
1620
return err

0 commit comments

Comments
 (0)