Ensure relocate_backup_gpt() is run last

Addresses issue #220
This commit is contained in:
2Shirt 2023-08-26 17:38:27 -07:00
parent 5147a4105f
commit 075a0d8541
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -226,8 +226,6 @@ def finalize_recovery(state: State, dry_run: bool = True) -> None:
return
# Run functions
if menu.options['Relocate Backup GPT']['Selected']:
relocate_backup_gpt(state, dry_run=dry_run)
if menu.options['Zero-fill Gaps']['Selected']:
zero_fill_gaps(
state,
@ -235,6 +233,9 @@ def finalize_recovery(state: State, dry_run: bool = True) -> None:
dry_run=dry_run,
extend_to_end=menu.options['Zero-fill Extra Space']['Selected'],
)
if menu.options['Relocate Backup GPT']['Selected']:
# NOTE: This needs to be run last to avoid corrupting/erasing the backup GPT
relocate_backup_gpt(state, dry_run=dry_run)
def is_missing_source_or_destination(state) -> bool:
@ -361,7 +362,6 @@ def relocate_backup_gpt(state: State, dry_run: bool = True) -> None:
and state.source.size < state.destination.size
and not state.source.parent
and str(state.source.raw_details.get('pttype', 'Unknown')).lower() == 'gpt'
and cli.ask('Relocate backup GPT to the end of the device?')
):
LOG.warning('Refusing to attempt a backup GPT relocation.')
return