Skip to content

Commit

Permalink
don't delete shared/boot parts in deleteAll (#1183880)
Browse files Browse the repository at this point in the history
This is one potential approach to help with #1183880 . It
changes the deleteAll behaviour as follows:

* Partitions known to be shared with other OSes won't be deleted
* Boot partitions won't be deleted if there are unknown parts

You can delete these partitions only by specifically targeting
them. It also adds a variant of the ConfirmDeleteDialog for
boot partitions, with text specifically explaining that they
might be needed for other OSes to boot.
  • Loading branch information
AdamWill committed Oct 1, 2015
1 parent a9f6e7e commit 80a8455
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
31 changes: 26 additions & 5 deletions pyanaconda/ui/gui/spokes/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
from blivet.errors import NotEnoughFreeSpaceError
from blivet.devicelibs import raid, crypto
from blivet.devices import LUKSDevice
from blivet.platform import platform

from pyanaconda.storage_utils import ui_storage_logger, device_type_from_autopart
from pyanaconda.storage_utils import DEVICE_TEXT_PARTITION, DEVICE_TEXT_MAP, DEVICE_TEXT_MD
Expand Down Expand Up @@ -1952,9 +1953,12 @@ def on_remove_clicked(self, button):
# on it. Thus, we first need to confirm with the user and then
# schedule actions to delete the thing.
dialog = ConfirmDeleteDialog(self.data)
protected = platform.bootStage1ConstraintDict["format_types"]
bootpart = device.format.type in protected
snapshots = (device.direct and not device.isleaf)
dialog.refresh(getattr(device.format, "mountpoint", ""),
device.name, root_name, snapshots=snapshots)
device.name, root_name, snapshots=snapshots,
bootpart=bootpart)
with self.main_window.enlightbox(dialog.window):
rc = dialog.run()

Expand All @@ -1963,16 +1967,33 @@ def on_remove_clicked(self, button):
return

if dialog.deleteAll:
for dev in (s._device for s in page.members):
self._destroy_device(dev)
else:
self._destroy_device(device)
otherpgs = (pg for pg in self._accordion.allPages if
pg.pageTitle != page.pageTitle)
otherdevs = []
for otherpg in otherpgs:
otherdevs.extend([mem._device.id for mem in otherpg.members])
# we never want to delete known-shared devs here. we also
# exclude 'device' as we'll unconditionally delete it later
for dev in (s._device for s in page.members if
s._device.id not in otherdevs and
s._device.id != device.id):
# we only want to delete boot partitions if they're not
# shared *and* we have no unknown partitions
if (not self.unusedDevices or dev.format.type not in protected):
log.info("deleteall: removed %s", dev.name)
self._destroy_device(dev)
else:
log.info("deleteall: didn't remove %s", dev.name)

# We do this even in deleteAll case, see above comment
self._destroy_device(device)

log.info("ui: removed device %s", device.name)

# Now that devices have been removed from the installation root,
# refreshing the display will have the effect of making them disappear.
# It's like they never existed.
self._storage_playground.roots = findExistingInstallations(self._storage_playground.devicetree)
self._updateSpaceDisplay()
self._do_refresh()

Expand Down
8 changes: 5 additions & 3 deletions pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,15 +377,15 @@ def on_delete_confirm_clicked(self, button, *args):
self.window.destroy()

# pylint: disable=arguments-differ
def refresh(self, mountpoint, device, rootName, snapshots=False):
def refresh(self, mountpoint, device, rootName, snapshots=False, bootpart=False):
GUIObject.refresh(self)
label = self.builder.get_object("confirmLabel")

if rootName and "_" in rootName:
rootName = rootName.replace("_", "__")
self._removeAll.set_label(
C_("GUI|Custom Partitioning|Confirm Delete Dialog",
"Delete _all other file systems in the %s root as well.")
"Delete _all other file systems which are only used by %s as well.")
% rootName)
self._removeAll.set_sensitive(rootName is not None)

Expand All @@ -394,7 +394,9 @@ def refresh(self, mountpoint, device, rootName, snapshots=False):
else:
txt = device

if not snapshots:
if bootpart:
label_text = _("%s may be a system boot partition! Deleting it may break other operating systems. Are you sure you want to delete it?") % txt
elif not snapshots:
label_text = _("Are you sure you want to delete all of the data on %s?") % txt
else:
label_text = _("Are you sure you want to delete all of the data on %s, including snapshots and/or subvolumes?") % txt
Expand Down

0 comments on commit 80a8455

Please sign in to comment.