mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Reorder code slightly in setupWorkingDirectory
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
beeec6d103
commit
bb66c16871
1 changed files with 17 additions and 16 deletions
|
@ -1105,28 +1105,29 @@ func (container *Container) getIpcContainer() (*Container, error) {
|
|||
}
|
||||
|
||||
func (container *Container) setupWorkingDirectory() error {
|
||||
if container.Config.WorkingDir != "" {
|
||||
container.Config.WorkingDir = filepath.Clean(container.Config.WorkingDir)
|
||||
if container.Config.WorkingDir == "" {
|
||||
return nil
|
||||
}
|
||||
container.Config.WorkingDir = filepath.Clean(container.Config.WorkingDir)
|
||||
|
||||
pth, err := container.GetResourcePath(container.Config.WorkingDir)
|
||||
if err != nil {
|
||||
pth, err := container.GetResourcePath(container.Config.WorkingDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pthInfo, err := os.Stat(pth)
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
pthInfo, err := os.Stat(pth)
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := system.MkdirAll(pth, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if pthInfo != nil && !pthInfo.IsDir() {
|
||||
return derr.ErrorCodeNotADir.WithArgs(container.Config.WorkingDir)
|
||||
if err := system.MkdirAll(pth, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if pthInfo != nil && !pthInfo.IsDir() {
|
||||
return derr.ErrorCodeNotADir.WithArgs(container.Config.WorkingDir)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue