check if the image to delete isn't parent of another

This commit is contained in:
Victor Vieux 2013-05-18 14:29:32 +00:00
parent f01990aad2
commit d7673274d2
1 changed files with 9 additions and 0 deletions

View File

@ -729,6 +729,15 @@ func (srv *Server) ImageDelete(name string) error {
}
}
}
// check is the image to delete isn't parent of another image
images, _ := srv.runtime.graph.All()
for _, image := range images {
if imgParent, err := image.GetParent(); err == nil && imgParent != nil {
if imgParent.Id == img.Id {
return fmt.Errorf("Can't delete %s, otherwise %s will be broken", name, image.ShortId())
}
}
}
if err := srv.runtime.graph.Delete(img.Id); err != nil {
return fmt.Errorf("Error deleting image %s: %s", name, err.Error())
}