if the Rename during an image delete fails, just delete the original dir

Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
Doug Davis 2014-09-22 07:47:20 -07:00
parent 5ad82d3ea6
commit 86a3a9a282

View file

@ -302,13 +302,17 @@ func (graph *Graph) Delete(name string) error {
return err
}
tmp, err := graph.Mktemp("")
if err != nil {
return err
}
graph.idIndex.Delete(id)
err = os.Rename(graph.ImageRoot(id), tmp)
if err != nil {
return err
if err == nil {
err = os.Rename(graph.ImageRoot(id), tmp)
// On err make tmp point to old dir and cleanup unused tmp dir
if err != nil {
os.RemoveAll(tmp)
tmp = graph.ImageRoot(id)
}
} else {
// On err make tmp point to old dir for cleanup
tmp = graph.ImageRoot(id)
}
// Remove rootfs data from the driver
graph.driver.Remove(id)