Fixed BlockPair().safety_check()
This commit is contained in:
parent
48eb4c13d7
commit
299b075eef
2 changed files with 11 additions and 10 deletions
|
|
@ -227,17 +227,17 @@ class BlockPair():
|
||||||
# Done
|
# Done
|
||||||
return complete
|
return complete
|
||||||
|
|
||||||
def safety_check(self, dry_run=False):
|
def safety_check(self):
|
||||||
"""Run safety check and abort if necessary."""
|
"""Run safety check and abort if necessary."""
|
||||||
dest_size = -1
|
dest_size = -1
|
||||||
if self.destination.exists():
|
if self.destination.exists():
|
||||||
dest_size = self.destination.stat().st_size
|
dest_obj = hw_obj.Disk(self.destination)
|
||||||
|
dest_size = dest_obj.details['size']
|
||||||
|
del dest_obj
|
||||||
|
|
||||||
# Raise exception if necessary
|
# Raise exception if necessary
|
||||||
if dry_run:
|
if dest_size < self.size:
|
||||||
std.print_warning(f'Assuming destination is okay ({self.destination})')
|
std.print_error(f'Invalid destination: {self.destination}')
|
||||||
elif dest_size < self.size:
|
|
||||||
std.print_error('Invalid destination: {self.destination}')
|
|
||||||
raise std.GenericAbort()
|
raise std.GenericAbort()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -537,8 +537,9 @@ class State():
|
||||||
)
|
)
|
||||||
|
|
||||||
# Safety Check #2
|
# Safety Check #2
|
||||||
for pair in self.block_pairs:
|
if not docopt_args['--dry-run']:
|
||||||
pair.safety_check(dry_run=docopt_args['--dry-run'])
|
for pair in self.block_pairs:
|
||||||
|
pair.safety_check()
|
||||||
|
|
||||||
def init_tmux(self):
|
def init_tmux(self):
|
||||||
"""Initialize tmux layout."""
|
"""Initialize tmux layout."""
|
||||||
|
|
@ -717,7 +718,7 @@ class State():
|
||||||
raise std.GenericAbort()
|
raise std.GenericAbort()
|
||||||
|
|
||||||
# Update settings
|
# Update settings
|
||||||
settings['Needs Format'] = not dry_run
|
settings['Needs Format'] = False
|
||||||
self.save_settings(settings, working_dir)
|
self.save_settings(settings, working_dir)
|
||||||
|
|
||||||
def retry_all_passes(self):
|
def retry_all_passes(self):
|
||||||
|
|
|
||||||
|
|
@ -739,7 +739,7 @@ def color_string(strings, colors, sep=' '):
|
||||||
|
|
||||||
# Convert to strings if necessary
|
# Convert to strings if necessary
|
||||||
try:
|
try:
|
||||||
iterator = iter(strings)
|
iter(strings)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
# Assuming single element passed, convert to string
|
# Assuming single element passed, convert to string
|
||||||
strings = (str(strings),)
|
strings = (str(strings),)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue