Fix destination size checks

Addresses issue #166
This commit is contained in:
2Shirt 2022-05-01 16:53:24 -07:00
parent af13a88c81
commit 859bc990e0
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -275,11 +275,17 @@ class BlockPair():
def safety_check(self):
"""Run safety check and abort if necessary."""
# TODO: Expand section to support non-Linux systems
dest_size = -1
if self.destination.exists():
dest_obj = hw_disk.Disk(self.destination)
dest_size = dest_obj.size
del dest_obj
if self.destination.is_block_device():
cmd = [
'lsblk', '--bytes', '--json',
'--nodeps', '--noheadings', '--output=size',
self.destination,
]
json_data = exe.get_json_from_command(cmd)
dest_size = json_data['blockdevices'][0]['size']
del json_data
# Check destination size if cloning
if not self.destination.is_file() and dest_size < self.size:
@ -712,13 +718,6 @@ class State():
# Set mode
self.mode = set_mode(docopt_args)
# Image mode is broken..
# TODO: Fix image mode
# Definitely for Linux, maybe for macOS
if self.mode == 'Image':
std.print_error("I'm sorry but image mode is currently broken...")
std.abort()
# Select source
self.source = get_object(docopt_args['<source>'])
if not self.source: