virtual: handle copy error in image restore

Add a proper error report for the shutil.copy operation in
image_restore() instead of silently returning.
master
Alejandro Sirgo Rica 2024-05-27 10:27:57 +02:00
parent 8de2b785a9
commit 72d8943576
1 changed files with 4 additions and 3 deletions

View File

@ -449,9 +449,10 @@ class OgVirtualOperations:
subprocess.run([cmd], shell=True, check=True)
try:
shutil.copy(f'{self.OG_IMAGES_PATH}/{name}', drive_path)
except:
return None
copy_src = f'{self.OG_IMAGES_PATH}/{name}'
shutil.copy(copy_src, drive_path)
except Exception as e:
raise OgError(f'Error trying to copy {copy_src} into {drive_path}: {e}') from e
subprocess.run([f'umount {self.OG_IMAGES_PATH}'], shell=True)
self.refresh(ogRest)