sys: mkdirAs: do chown if dir already exists
Fix `buildkitd --group GROUP` issue when `/run/buildkit` already exists
and is owned by the root.
@@ -68,11 +68,11 @@ func GetLocalListener(path string, uid, gid int) (net.Listener, error) {
}
func mkdirAs(path string, uid, gid int) error {
- if _, err := os.Stat(path); err == nil || !os.IsNotExist(err) {
+ if _, err := os.Stat(path); !os.IsNotExist(err) {
return err
}
- if err := os.Mkdir(path, 0770); err != nil {
+ if err := os.MkdirAll(path, 0770); err != nil {
return err
}
