mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Merge pull request #129242 from tallclair/windows-mkdir
[windows] Don't chmod existing directory in MkdirAll
This commit is contained in:
commit
87defb5fb1
@ -94,14 +94,21 @@ func IsUnixDomainSocket(filePath string) (bool, error) {
|
||||
// permissions once the directory is created.
|
||||
func MkdirAll(path string, perm os.FileMode) error {
|
||||
klog.V(6).InfoS("Function MkdirAll starts", "path", path, "perm", perm)
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
// Path already exists: nothing to do.
|
||||
return nil
|
||||
} else if !os.IsNotExist(err) {
|
||||
return fmt.Errorf("error checking path %s: %w", path, err)
|
||||
}
|
||||
|
||||
err := os.MkdirAll(path, perm)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error creating directory %s: %v", path, err)
|
||||
return fmt.Errorf("error creating directory %s: %w", path, err)
|
||||
}
|
||||
|
||||
err = Chmod(path, perm)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error setting permissions for directory %s: %v", path, err)
|
||||
return fmt.Errorf("error setting permissions for directory %s: %w", path, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user