mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fix call to nil stat
Fixes #10242 Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
parent
f3aed2a297
commit
811b138f7e
2 changed files with 8 additions and 20 deletions
|
@ -53,6 +53,8 @@ func (daemon *Daemon) setHostConfig(container *Container, hostConfig *runconfig.
|
||||||
if err := parseSecurityOpt(container, hostConfig); err != nil {
|
if err := parseSecurityOpt(container, hostConfig); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: this should be handled by the volume subsystem
|
||||||
// Validate the HostConfig binds. Make sure that:
|
// Validate the HostConfig binds. Make sure that:
|
||||||
// the source exists
|
// the source exists
|
||||||
for _, bind := range hostConfig.Binds {
|
for _, bind := range hostConfig.Binds {
|
||||||
|
|
|
@ -86,31 +86,15 @@ func (v *Volume) AddContainer(containerId string) {
|
||||||
v.lock.Unlock()
|
v.lock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Volume) createIfNotExist() error {
|
|
||||||
if stat, err := os.Stat(v.Path); err != nil && os.IsNotExist(err) {
|
|
||||||
if stat.IsDir() {
|
|
||||||
os.MkdirAll(v.Path, 0755)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := os.MkdirAll(filepath.Dir(v.Path), 0755); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
f, err := os.OpenFile(v.Path, os.O_CREATE, 0755)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
f.Close()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *Volume) initialize() error {
|
func (v *Volume) initialize() error {
|
||||||
v.lock.Lock()
|
v.lock.Lock()
|
||||||
defer v.lock.Unlock()
|
defer v.lock.Unlock()
|
||||||
|
|
||||||
if err := v.createIfNotExist(); err != nil {
|
if _, err := os.Stat(v.Path); err != nil && os.IsNotExist(err) {
|
||||||
|
if err := os.MkdirAll(v.Path, 0755); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err := os.MkdirAll(v.configPath, 0755); err != nil {
|
if err := os.MkdirAll(v.configPath, 0755); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -133,6 +117,7 @@ func (v *Volume) ToDisk() error {
|
||||||
defer v.lock.Unlock()
|
defer v.lock.Unlock()
|
||||||
return v.toDisk()
|
return v.toDisk()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Volume) toDisk() error {
|
func (v *Volume) toDisk() error {
|
||||||
data, err := json.Marshal(v)
|
data, err := json.Marshal(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -146,6 +131,7 @@ func (v *Volume) toDisk() error {
|
||||||
|
|
||||||
return ioutil.WriteFile(pth, data, 0666)
|
return ioutil.WriteFile(pth, data, 0666)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Volume) FromDisk() error {
|
func (v *Volume) FromDisk() error {
|
||||||
v.lock.Lock()
|
v.lock.Lock()
|
||||||
defer v.lock.Unlock()
|
defer v.lock.Unlock()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue