From 075a0d8541505ef5c32289ce9a0e9e3d6defa181 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sat, 26 Aug 2023 17:38:27 -0700 Subject: [PATCH 1/2] Ensure relocate_backup_gpt() is run last Addresses issue #220 --- scripts/wk/clone/ddrescue.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/wk/clone/ddrescue.py b/scripts/wk/clone/ddrescue.py index 3f31cb6d..43834004 100644 --- a/scripts/wk/clone/ddrescue.py +++ b/scripts/wk/clone/ddrescue.py @@ -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 From f7345a8a54bd282902bf412d7070beb129b00c05 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sat, 26 Aug 2023 17:39:27 -0700 Subject: [PATCH 2/2] Improve full_disk_clone definition --- scripts/wk/clone/ddrescue.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/wk/clone/ddrescue.py b/scripts/wk/clone/ddrescue.py index 43834004..ce5d60c5 100644 --- a/scripts/wk/clone/ddrescue.py +++ b/scripts/wk/clone/ddrescue.py @@ -649,11 +649,13 @@ def zero_fill_gaps( ) -> None: """Zero-fill any gaps on the destination.""" #fake_settings_menu = menus.settings(state.mode) - full_disk_clone = False + full_disk_clone = bool( + state.mode == 'Clone' + and len(state.block_pairs) == 1 + and not state.source.parent + ) larger_destination = state.source.size < dest_size percent_recovered = state.get_percent_recovered() - if state.mode == 'Clone' and len(state.block_pairs) == 1: - full_disk_clone = True # Bail early if percent_recovered == 100 and not (larger_destination and extend_to_end):