Recursively remove known child-media if possible

Here you can provide suggestions on how to improve the product, website, etc.
Post Reply
______________
Posts: 4
Joined: 4. Mar 2022, 08:14

Recursively remove known child-media if possible

Post by ______________ »

I am using VirtualBox 7.0.14 r161095 with the expansion pack of the same version.

I am diagnosing a problem and I frequently end up with a situation like this:
(I was planning to add a screenshot here, but it seems that attachments are disabled in the suggestions forum, so a textual description will have to suffice.)
I have removed all VMs from the Virtual Box Manager. In "Tools -> Hard disks", I see a tree for the known media that correspond to one of my VMs and its snapshots. All entries are shown with a yellow warning symbol, but let's not worry too much about how that happened (unless it's unexpectedly relevant) and focus on what I want to do now:

I want to remove all of those known media. Ideally I would simply right-click the root node and select "Remove". When I do that, I get asked for confirmation ("Are you sure you want to remove the virtual hard disk <...> from the list of known disk image files?"), which I confirm by clicking "Remove". The notification center opens up with a notification that says:
Can't close medium ...
Failed to close the disk image file <...>.
Cannot close medium '<...>' because it has 2 child media.
Well... then... remove those too?

If I start at the leaf nodes of the tree and remove each known media individually, it works just fine. But that's super cumbersome. The program should ask "This media has <n> child media. Remove those and all descendant child media too? [Yes, remove all] [Cancel]".

When all known media are shown with a yellow warning symbol, it's at least acceptably fast to hit "Ctrl+Shift+R, Left-Arrow, Space" repeatedly to remove batches quickly, but I typically end up with OK media (which require more elaborate dialog interactions) and non-OK media interleaved, so it's not great.

I know that this requires some thinking about more complicated cases (e.g. remember the choice for deleting or keeping the files on disk, but only ask if it's required by at least one media in the tree), but if it's OK to not make this operation "atomic" (i.e. either remove the entire tree or change nothing) (and I think that would be OK), those shouldn't be "hard" problems, so a relatively naive solution would suffice.
Post Reply