Check if GID is already the group if so no need to chown
This commit is contained in:
parent
9136f02d4c
commit
c7cef1773e
1 changed files with 7 additions and 2 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"unicode"
|
||||
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
|
@ -400,8 +401,12 @@ func checkGroups(forceYes *bool) (*user.Group, error) {
|
|||
if err != nil {
|
||||
return dockerGroup, fmt.Errorf("unable to convert group ID to int: %s", err)
|
||||
}
|
||||
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)
|
||||
if stat, err := os.Stat(csConfig.DbConfig.DbPath); err == nil {
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue