Added another safety check for block pairs
* Needed one more check since clone pairs were assumed to be okay
This commit is contained in:
parent
5d0ed475a6
commit
ac04a3ddc5
1 changed files with 17 additions and 9 deletions
|
|
@ -227,6 +227,19 @@ class BlockPair():
|
||||||
# Done
|
# Done
|
||||||
return complete
|
return complete
|
||||||
|
|
||||||
|
def safety_check(self, dry_run=False):
|
||||||
|
"""Run safety check and abort if necessary."""
|
||||||
|
dest_size = -1
|
||||||
|
if self.destination.exists():
|
||||||
|
dest_size = self.destination.stat().st_size
|
||||||
|
|
||||||
|
# Raise exception if necessary
|
||||||
|
if dry_run:
|
||||||
|
std.print_warning(f'Assuming destination is okay ({self.destination})')
|
||||||
|
elif dest_size < self.size:
|
||||||
|
std.print_error('Invalid destination: {self.destination}')
|
||||||
|
raise std.GenericAbort()
|
||||||
|
|
||||||
|
|
||||||
class State():
|
class State():
|
||||||
"""Object for tracking hardware diagnostic data."""
|
"""Object for tracking hardware diagnostic data."""
|
||||||
|
|
@ -323,7 +336,6 @@ class State():
|
||||||
bp_dest = self.destination
|
bp_dest = self.destination
|
||||||
self.add_block_pair(part, bp_dest, working_dir)
|
self.add_block_pair(part, bp_dest, working_dir)
|
||||||
|
|
||||||
|
|
||||||
def confirm_selections(
|
def confirm_selections(
|
||||||
self, mode, prompt, working_dir=None, source_parts=None):
|
self, mode, prompt, working_dir=None, source_parts=None):
|
||||||
"""Show selection details and prompt for confirmation."""
|
"""Show selection details and prompt for confirmation."""
|
||||||
|
|
@ -524,8 +536,9 @@ class State():
|
||||||
source_parts, working_dir, dry_run=docopt_args['--dry-run'],
|
source_parts, working_dir, dry_run=docopt_args['--dry-run'],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Done
|
# Safety Check #2
|
||||||
# Ready for main menu
|
for pair in self.block_pairs:
|
||||||
|
pair.safety_check(dry_run=docopt_args['--dry-run'])
|
||||||
|
|
||||||
def init_tmux(self):
|
def init_tmux(self):
|
||||||
"""Initialize tmux layout."""
|
"""Initialize tmux layout."""
|
||||||
|
|
@ -689,12 +702,7 @@ class State():
|
||||||
_f.write('\n'.join(sfdisk_script))
|
_f.write('\n'.join(sfdisk_script))
|
||||||
|
|
||||||
# Format disk
|
# Format disk
|
||||||
if dry_run:
|
if not dry_run:
|
||||||
std.print_warning('Not formatting disk during dry run')
|
|
||||||
std.print_info('Script for sfdisk:')
|
|
||||||
std.print_report(sfdisk_script)
|
|
||||||
std.pause()
|
|
||||||
else:
|
|
||||||
# TODO
|
# TODO
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue