Fix crashing while restoring a backup file with the wrong encoding

Fixes sentry issue CURA-24R
This commit is contained in:
Kostas Karmas 2021-04-19 14:24:42 +02:00
parent ae595affc3
commit 7e98fb7fb0

View file

@ -147,7 +147,12 @@ class Backup:
secrets = self._obfuscate() secrets = self._obfuscate()
version_data_dir = Resources.getDataStoragePath() version_data_dir = Resources.getDataStoragePath()
archive = ZipFile(io.BytesIO(self.zip_file), "r") try:
archive = ZipFile(io.BytesIO(self.zip_file), "r")
except LookupError as e:
Logger.log("d", f"The following error occurred while trying to restore a Cura backup: {str(e)}")
self._showMessage(self.catalog.i18nc("@info:backup_failed", "The following error occurred while trying to restore a Cura backup:") + str(e))
return False
extracted = self._extractArchive(archive, version_data_dir) extracted = self._extractArchive(archive, version_data_dir)
# Under Linux, preferences are stored elsewhere, so we copy the file to there. # Under Linux, preferences are stored elsewhere, so we copy the file to there.