Properly handle damaged filesystems
This commit is contained in:
parent
da0dae2083
commit
075e25462e
2 changed files with 10 additions and 3 deletions
|
|
@ -116,7 +116,12 @@ def get_partition_details(disk, partition):
|
||||||
|
|
||||||
if 'Letter' in details:
|
if 'Letter' in details:
|
||||||
# Disk usage
|
# Disk usage
|
||||||
tmp = shutil.disk_usage('{}:\\'.format(details['Letter']))
|
try:
|
||||||
|
tmp = psutil.disk_usage('{}:\\'.format(details['Letter']))
|
||||||
|
except OSError as err:
|
||||||
|
details['FileSystem'] = 'Unknown'
|
||||||
|
details['Error'] = err.strerror
|
||||||
|
else:
|
||||||
details['Used Space'] = human_readable_size(tmp.used)
|
details['Used Space'] = human_readable_size(tmp.used)
|
||||||
|
|
||||||
# fsutil details
|
# fsutil details
|
||||||
|
|
@ -146,7 +151,7 @@ def get_partition_details(disk, partition):
|
||||||
details['Name'] = details.get('Volume Name', '')
|
details['Name'] = details.get('Volume Name', '')
|
||||||
|
|
||||||
# Set FileSystem Type
|
# Set FileSystem Type
|
||||||
if details.get('FileSystem', '') != 'RAW':
|
if details.get('FileSystem', '') not in ['RAW', 'Unknown']:
|
||||||
details['FileSystem'] = details.get('File System Name', 'Unknown')
|
details['FileSystem'] = details.get('File System Name', 'Unknown')
|
||||||
|
|
||||||
return details
|
return details
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,8 @@ def menu_backup():
|
||||||
data = par['Display String']
|
data = par['Display String']
|
||||||
if par['Number'] in disk['Bad Partitions']:
|
if par['Number'] in disk['Bad Partitions']:
|
||||||
show_data(message=message, data=data, width=30, warning=True)
|
show_data(message=message, data=data, width=30, warning=True)
|
||||||
|
if 'Error' in par:
|
||||||
|
show_data(message='', data=par['Error'], error=True)
|
||||||
elif par['Image Exists']:
|
elif par['Image Exists']:
|
||||||
show_data(message=message, data=data, width=30, info=True)
|
show_data(message=message, data=data, width=30, info=True)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue