From df5c52d1c60435a8b61051f3a40fa9a52e7ae1df Mon Sep 17 00:00:00 2001 From: Kostas Karmas Date: Fri, 16 Apr 2021 15:55:06 +0200 Subject: [PATCH] Fail gracefully if writing the backup to a temp file crashes Fixes sentry issue CURA-21W --- plugins/CuraDrive/src/RestoreBackupJob.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/CuraDrive/src/RestoreBackupJob.py b/plugins/CuraDrive/src/RestoreBackupJob.py index c60de116e0..067e0ca8c2 100644 --- a/plugins/CuraDrive/src/RestoreBackupJob.py +++ b/plugins/CuraDrive/src/RestoreBackupJob.py @@ -61,7 +61,11 @@ class RestoreBackupJob(Job): app = CuraApplication.getInstance() bytes_read = reply.read(self.DISK_WRITE_BUFFER_SIZE) while bytes_read: - write_backup.write(bytes_read) + try: + write_backup.write(bytes_read) + except Exception as e: + Logger.logException("e", "An error occurred while writing the backup to a temporary file: {}. The restoration of the backup is aborted.".format(e)) + return bytes_read = reply.read(self.DISK_WRITE_BUFFER_SIZE) app.processEvents()