From b2e287520c72b77883394204665274807962f11e Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Mon, 3 Sep 2018 21:32:31 -0600 Subject: [PATCH 1/7] Fix help flags --- .bin/Scripts/ddrescue-tui-menu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bin/Scripts/ddrescue-tui-menu b/.bin/Scripts/ddrescue-tui-menu index 988ec0fa..4bec6230 100755 --- a/.bin/Scripts/ddrescue-tui-menu +++ b/.bin/Scripts/ddrescue-tui-menu @@ -32,7 +32,7 @@ if __name__ == '__main__': pass # Show usage - if re.search(r'-*(h|help|\?)', str(sys.argv), re.IGNORECASE): + if re.search(r'-+(h|help)', str(sys.argv), re.IGNORECASE): show_usage(script_name) exit_script() From 7cfdddcfbdee402bc1caedfcb522c65127fa300d Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Mon, 3 Sep 2018 21:34:14 -0600 Subject: [PATCH 2/7] Fix using image file for clone source --- .bin/Scripts/functions/ddrescue.py | 1 + 1 file changed, 1 insertion(+) diff --git a/.bin/Scripts/functions/ddrescue.py b/.bin/Scripts/functions/ddrescue.py index b890cc59..2af666a0 100644 --- a/.bin/Scripts/functions/ddrescue.py +++ b/.bin/Scripts/functions/ddrescue.py @@ -41,6 +41,7 @@ class BaseObj(): """Base object used by DevObj, DirObj, and ImageObj.""" def __init__(self, path): self.type = 'base' + self.parent = None self.path = os.path.realpath(path) self.set_details() From dbf4559e14b71eeeddf70c2a8f5c3d0ec2c2ac00 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Mon, 3 Sep 2018 21:39:32 -0600 Subject: [PATCH 3/7] Adjusted image/map filenames * Partition filenames should include '_pX_' instead of just '_X_' * Trailing whitespace should be removed --- .bin/Scripts/functions/ddrescue.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.bin/Scripts/functions/ddrescue.py b/.bin/Scripts/functions/ddrescue.py index 2af666a0..31f22446 100644 --- a/.bin/Scripts/functions/ddrescue.py +++ b/.bin/Scripts/functions/ddrescue.py @@ -207,13 +207,17 @@ class DevObj(BaseObj): self.prefix = '{m_size}_{model}'.format( m_size=self.model_size, model=self.model) + self.prefix = self.prefix.strip() if self.parent: # Add child device details - self.prefix += '_{c_num}_{c_size}{sep}{c_label}'.format( - c_num=self.path.replace(self.parent, ''), + c_num = self.path.replace(self.parent, '') + self.prefix += '_{c_prefix}{c_num}_{c_size}{sep}{c_label}'.format( + c_prefix='p' if len(c_num) == 1 else '', + c_num=c_num, c_size=self.details.get('size', 'UNKNOWN'), sep='_' if self.label else '', c_label=self.label) + self.prefix = self.prefix.strip() class DirObj(BaseObj): From 86fc23aed80b4317375e573047f072c2161f7852 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Mon, 3 Sep 2018 21:42:37 -0600 Subject: [PATCH 4/7] Fix pass number in status pane * It was using the internal 0-2 instead of the display 1-3 --- .bin/Scripts/functions/ddrescue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bin/Scripts/functions/ddrescue.py b/.bin/Scripts/functions/ddrescue.py index 31f22446..e573e255 100644 --- a/.bin/Scripts/functions/ddrescue.py +++ b/.bin/Scripts/functions/ddrescue.py @@ -165,7 +165,7 @@ class BlockPair(): self.rescued_percent = map_data['rescued'] self.rescued = (self.rescued_percent * self.size) / 100 self.status[pass_num] = get_formatted_status( - label='Pass {}'.format(pass_num), + label='Pass {}'.format(pass_num+1), data=(self.rescued/self.size)*100) From 9dbfce94d4f31b245bca61f5599cd4342bea0630 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Mon, 3 Sep 2018 21:44:28 -0600 Subject: [PATCH 5/7] Fix auto continue logic --- .bin/Scripts/functions/ddrescue.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.bin/Scripts/functions/ddrescue.py b/.bin/Scripts/functions/ddrescue.py index e573e255..fcdcec17 100644 --- a/.bin/Scripts/functions/ddrescue.py +++ b/.bin/Scripts/functions/ddrescue.py @@ -71,6 +71,7 @@ class BlockPair(): self.pass_done = [False, False, False] self.resumed = False self.rescued = 0 + self.rescued_percent = 0 self.status = ['Pending', 'Pending', 'Pending'] self.size = source.size # Set dest paths @@ -336,7 +337,7 @@ class RecoveryState(): """Gets minimum pass rescued percentage, returns float.""" min_percent = 100 for bp in self.block_pairs: - min_percent = min(min_percent, bp.rescued) + min_percent = min(min_percent, bp.rescued_percent) return min_percent def retry_all_passes(self): From bd47f089961eed3dfb69bfad8797efd198ba97f3 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Mon, 3 Sep 2018 21:45:46 -0600 Subject: [PATCH 6/7] Removed (Whole) label when imaging * If only one partition was selected it would be incorrectly labeled "Whole" * Easier to remove the label than rework the data structures --- .bin/Scripts/functions/ddrescue.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.bin/Scripts/functions/ddrescue.py b/.bin/Scripts/functions/ddrescue.py index fcdcec17..d3ca8456 100644 --- a/.bin/Scripts/functions/ddrescue.py +++ b/.bin/Scripts/functions/ddrescue.py @@ -1215,10 +1215,6 @@ def update_sidepane(state): for bp in state.block_pairs: if state.source.is_image(): output.append('{BLUE}Image File{CLEAR}'.format(**COLORS)) - elif state.mode == 'image' and len(state.block_pairs) == 1: - output.append('{BLUE}{source} {YELLOW}(Whole){CLEAR}'.format( - source=bp.source_path, - **COLORS)) else: output.append('{BLUE}{source}{CLEAR}'.format( source=bp.source_path, From d35dba75397da4a6cc19e8d44f80e83d96517312 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Mon, 3 Sep 2018 22:58:20 -0600 Subject: [PATCH 7/7] Prevent crash when retrying recovery * IMO ddrescue was exiting too quickly to load the map data so I'll assume 0b --- .bin/Scripts/functions/ddrescue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bin/Scripts/functions/ddrescue.py b/.bin/Scripts/functions/ddrescue.py index d3ca8456..ae1194a9 100644 --- a/.bin/Scripts/functions/ddrescue.py +++ b/.bin/Scripts/functions/ddrescue.py @@ -163,7 +163,7 @@ class BlockPair(): """Update progress using map file.""" if os.path.exists(self.map_path): map_data = read_map_file(self.map_path) - self.rescued_percent = map_data['rescued'] + self.rescued_percent = map_data.get('rescued', 0) self.rescued = (self.rescued_percent * self.size) / 100 self.status[pass_num] = get_formatted_status( label='Pass {}'.format(pass_num+1),