Browse Source

Windows: Rename layers before deletion

Signed-off-by: Darren Stahl <darst@microsoft.com>
Darren Stahl 8 năm trước cách đây
mục cha
commit
be68006d19
1 tập tin đã thay đổi với 12 bổ sung2 xóa
  1. 12 2
      daemon/graphdriver/windows/windows.go

+ 12 - 2
daemon/graphdriver/windows/windows.go

@@ -243,8 +243,18 @@ func (d *Driver) Remove(id string) error {
 	if err != nil {
 		return err
 	}
-	os.RemoveAll(filepath.Join(d.info.HomeDir, "sysfile-backups", rID)) // ok to fail
-	return hcsshim.DestroyLayer(d.info, rID)
+
+	layerPath := filepath.Join(d.info.HomeDir, rID)
+	tmpID := fmt.Sprintf("%s-removing", rID)
+	tmpLayerPath := filepath.Join(d.info.HomeDir, tmpID)
+	if err := os.Rename(layerPath, tmpLayerPath); err != nil && !os.IsNotExist(err) {
+		return err
+	}
+	if err := hcsshim.DestroyLayer(d.info, tmpID); err != nil {
+		logrus.Errorf("Failed to DestroyLayer %s: %s", id, err)
+	}
+
+	return nil
 }
 
 // Get returns the rootfs path for the id. This will mount the dir at its given path.