Check if GID is already the group if so no need to chown
This commit is contained in:
parent
9136f02d4c
commit
c7cef1773e
|
@ -9,6 +9,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/AlecAivazis/survey/v2"
|
"github.com/AlecAivazis/survey/v2"
|
||||||
|
@ -400,8 +401,12 @@ func checkGroups(forceYes *bool) (*user.Group, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return dockerGroup, fmt.Errorf("unable to convert group ID to int: %s", err)
|
return dockerGroup, fmt.Errorf("unable to convert group ID to int: %s", err)
|
||||||
}
|
}
|
||||||
if err := os.Chown(csConfig.DbConfig.DbPath, 0, intID); err != nil {
|
if stat, err := os.Stat(csConfig.DbConfig.DbPath); err == nil {
|
||||||
return dockerGroup, fmt.Errorf("unable to chown sqlite db file '%s': %s", csConfig.DbConfig.DbPath, err)
|
if uint32(intID) != stat.Sys().(*syscall.Stat_t).Gid {
|
||||||
|
if err := os.Chown(csConfig.DbConfig.DbPath, 0, intID); err != nil {
|
||||||
|
return dockerGroup, fmt.Errorf("unable to chown sqlite db file '%s': %s", csConfig.DbConfig.DbPath, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return dockerGroup, nil
|
return dockerGroup, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue