|
@@ -513,12 +513,17 @@ func (d *Driver) getLowerDirs(id string) ([]string, error) {
|
|
|
|
|
|
// Remove cleans the directories that are created for this id.
|
|
// Remove cleans the directories that are created for this id.
|
|
func (d *Driver) Remove(id string) error {
|
|
func (d *Driver) Remove(id string) error {
|
|
|
|
+ if id == "" {
|
|
|
|
+ return fmt.Errorf("refusing to remove the directories: id is empty")
|
|
|
|
+ }
|
|
d.locker.Lock(id)
|
|
d.locker.Lock(id)
|
|
defer d.locker.Unlock(id)
|
|
defer d.locker.Unlock(id)
|
|
dir := d.dir(id)
|
|
dir := d.dir(id)
|
|
lid, err := ioutil.ReadFile(path.Join(dir, "link"))
|
|
lid, err := ioutil.ReadFile(path.Join(dir, "link"))
|
|
if err == nil {
|
|
if err == nil {
|
|
- if err := os.RemoveAll(path.Join(d.home, linkDir, string(lid))); err != nil {
|
|
|
|
|
|
+ if len(lid) == 0 {
|
|
|
|
+ logrus.WithField("storage-driver", "overlay2").Errorf("refusing to remove empty link for layer %v", id)
|
|
|
|
+ } else if err := os.RemoveAll(path.Join(d.home, linkDir, string(lid))); err != nil {
|
|
logrus.WithField("storage-driver", "overlay2").Debugf("Failed to remove link: %v", err)
|
|
logrus.WithField("storage-driver", "overlay2").Debugf("Failed to remove link: %v", err)
|
|
}
|
|
}
|
|
}
|
|
}
|