diff options
author | Jeremy Katz <katzj@redhat.com> | 2001-08-14 18:39:06 +0000 |
---|---|---|
committer | Jeremy Katz <katzj@redhat.com> | 2001-08-14 18:39:06 +0000 |
commit | 4c0f6efe69c15d4e25534edd6f899491e2479272 (patch) | |
tree | 51cde13799da28fa8d1ef82534e960d5668e077b /textw/partition_text.py | |
parent | 8ecd37eee2c4be84fd6c94b933a14077f5423b09 (diff) | |
download | anaconda-4c0f6efe69c15d4e25534edd6f899491e2479272.tar.gz anaconda-4c0f6efe69c15d4e25534edd6f899491e2479272.tar.xz anaconda-4c0f6efe69c15d4e25534edd6f899491e2479272.zip |
restoring the backup copy doesn't work...
if processPartitioning fails, we need to remove the request we just added
from the request list and, if this isn't a "new new" request, add the old
one back in. this also brings in clearer semantics for a request being
new as opposed to relying on checking the combination of
origrequest.device and origrequest.type
fixes 51730 and should also fix a few other places where we get devices
of None (eg 51667, 50905, 50858, and possibly others)
Diffstat (limited to 'textw/partition_text.py')
-rw-r--r-- | textw/partition_text.py | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/textw/partition_text.py b/textw/partition_text.py index ff23c69de..f88d54b09 100644 --- a/textw/partition_text.py +++ b/textw/partition_text.py @@ -534,7 +534,8 @@ class PartitionWindow: self.drivelist.key2item = {} self.drivelist.item2key = {} - def editPartitionRequest(self, origrequest): + # isNew implies that this request has never been successfully used before + def editPartitionRequest(self, origrequest, isNew = 0): self.oldMount = None poplevel = GridFormHelp(self.screen,_("Add Partition"),"addpart", 1, 6) @@ -780,15 +781,19 @@ class PartitionWindow: if not queryNoFormatPreExisting(self.intf): continue - # backup current (known working) configuration - backpart = self.partitions.copy() - if origrequest.device or origrequest.type != REQUEST_NEW: + if not isNew: self.partitions.removeRequest(origrequest) self.partitions.addRequest(request) if self.refresh(): - self.partitions = backpart - self.refresh() + # the add failed; remove what we just added and put + # back what was there if we removed it + self.partitions.removeRequest(request) + if not isNew: + self.partitions.addRequest(origrequest) + if self.refresh(): + # this worked before and doesn't now... + raise RuntimeError, "Returning partitions to state prior to edit failed" else: break @@ -796,8 +801,8 @@ class PartitionWindow: self.shutdownUI() self.screen.popWindow() - - def editRaidRequest(self, raidrequest): + # isNew implies that this request has never been successfully used before + def editRaidRequest(self, raidrequest, isNew = 0): poplevel = GridFormHelp(self.screen, _("Make RAID Device"), "makeraid", 1, 6) # mount point entry @@ -897,22 +902,21 @@ class PartitionWindow: "%s" % (err)) continue - # backup current (known working) configuration - backpart = self.partitions.copy() - - # XXX should only remove if we know we put it in before - try: + if not isNew: self.partitions.removeRequest(raidrequest) - except: - pass self.partitions.addRequest(request) if self.refresh(): - self.partitions = backpart - self.refresh() + # how can this fail? well, if it does, do the remove new, + # add old back in dance + self.partitions.removeRequest(request) + if not isNew: + self.partitions.addRequest(raidrequest) + if self.refresh(): + raise RuntimeError, "Returning partitions to state prior to RAID edit failed" else: - break + break break @@ -922,12 +926,12 @@ class PartitionWindow: def newCb(self): request = PartitionSpec(fileSystemTypeGetDefault(), REQUEST_NEW, 1) - self.editPartitionRequest(request) + self.editPartitionRequest(request, isNew = 1) def makeraidCb(self): request = PartitionSpec(fileSystemTypeGetDefault(), REQUEST_RAID, 1) - self.editRaidRequest(request) + self.editRaidRequest(request, isNew = 1) def editCb(self): |