mirror of
https://github.com/containers/podman.git
synced 2025-06-24 19:42:56 +08:00
Merge pull request #8172 from rhatdan/storage
[NO TESTS NEEDED] allow the removal of storage images
This commit is contained in:
@ -325,6 +325,15 @@ func (r *Runtime) LoadImageFromSingleImageArchive(ctx context.Context, writer io
|
||||
return "", errors.Wrapf(saveErr, "error pulling image")
|
||||
}
|
||||
|
||||
// RemoveImageFromStorage goes directly to storage and attempts to remove
|
||||
// the specified image. This is dangerous and should only be done if libpod
|
||||
// reports that image is not known. This call is useful if you have a corrupted
|
||||
// image that was never fully added to the libpod database.
|
||||
func (r *Runtime) RemoveImageFromStorage(id string) error {
|
||||
_, err := r.store.DeleteImage(id, true)
|
||||
return err
|
||||
}
|
||||
|
||||
func getImageNames(images []*image.Image) string {
|
||||
var names string
|
||||
for i := range images {
|
||||
|
@ -640,6 +640,10 @@ func (ir *ImageEngine) Remove(ctx context.Context, images []string, opts entitie
|
||||
for _, id := range images {
|
||||
img, err := ir.Libpod.ImageRuntime().NewFromLocal(id)
|
||||
if err != nil {
|
||||
// attempt to remove image from storage
|
||||
if forceErr := ir.Libpod.RemoveImageFromStorage(id); forceErr == nil {
|
||||
continue
|
||||
}
|
||||
rmErrors = append(rmErrors, err)
|
||||
continue
|
||||
}
|
||||
|
Reference in New Issue
Block a user