Properly handle damaged filesystems

This commit is contained in:
Alan Mason 2017-12-02 16:58:45 -08:00
parent da0dae2083
commit 075e25462e
2 changed files with 10 additions and 3 deletions

View file

@ -116,8 +116,13 @@ def get_partition_details(disk, partition):
if 'Letter' in details:
# Disk usage
tmp = shutil.disk_usage('{}:\\'.format(details['Letter']))
details['Used Space'] = human_readable_size(tmp.used)
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)
# fsutil details
cmd = [
@ -146,7 +151,7 @@ def get_partition_details(disk, partition):
details['Name'] = details.get('Volume Name', '')
# Set FileSystem Type
if details.get('FileSystem', '') != 'RAW':
if details.get('FileSystem', '') not in ['RAW', 'Unknown']:
details['FileSystem'] = details.get('File System Name', 'Unknown')
return details

View file

@ -125,6 +125,8 @@ def menu_backup():
data = par['Display String']
if par['Number'] in disk['Bad Partitions']:
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']:
show_data(message=message, data=data, width=30, info=True)
else: