mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #18907 from mountkin/rm
ingnore the NotExist error when removing inexistent files
This commit is contained in:
commit
603d488a00
3 changed files with 10 additions and 4 deletions
|
@ -278,7 +278,10 @@ func (d *Driver) Remove(id string) error {
|
|||
if err := subvolDelete(d.subvolumesDir(), id); err != nil {
|
||||
return err
|
||||
}
|
||||
return os.RemoveAll(dir)
|
||||
if err := os.RemoveAll(dir); err != nil && !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get the requested filesystem id.
|
||||
|
|
|
@ -322,7 +322,10 @@ func (d *Driver) dir(id string) string {
|
|||
|
||||
// Remove cleans the directories that are created for this id.
|
||||
func (d *Driver) Remove(id string) error {
|
||||
return os.RemoveAll(d.dir(id))
|
||||
if err := os.RemoveAll(d.dir(id)); err != nil && !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get creates and mounts the required file system for the given id and returns the mount path.
|
||||
|
|
|
@ -104,10 +104,10 @@ func (d *Driver) dir(id string) string {
|
|||
|
||||
// Remove deletes the content from the directory for a given id.
|
||||
func (d *Driver) Remove(id string) error {
|
||||
if _, err := os.Stat(d.dir(id)); err != nil {
|
||||
if err := os.RemoveAll(d.dir(id)); err != nil && !os.IsNotExist(err) {
|
||||
return err
|
||||
}
|
||||
return os.RemoveAll(d.dir(id))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get returns the directory for the given id.
|
||||
|
|
Loading…
Reference in a new issue