mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-12-05 16:51:12 -07:00
Catch errors when backing up the preferences file
The file may not exist. In fact, that may be the whole reason why people want to restore a back-up. Try it, and give an error if it fails. Fixes Sentry issue CURA-2QT.
This commit is contained in:
parent
efcd83f82f
commit
a1ecea020c
1 changed files with 5 additions and 2 deletions
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Copyright (c) 2021 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import io
|
||||
|
|
@ -168,7 +168,10 @@ class Backup:
|
|||
preferences_file = Resources.getPath(Resources.Preferences, "{}.cfg".format(preferences_file_name))
|
||||
backup_preferences_file = os.path.join(version_data_dir, "{}.cfg".format(preferences_file_name))
|
||||
Logger.log("d", "Moving preferences file from %s to %s", backup_preferences_file, preferences_file)
|
||||
shutil.move(backup_preferences_file, preferences_file)
|
||||
try:
|
||||
shutil.move(backup_preferences_file, preferences_file)
|
||||
except EnvironmentError as e:
|
||||
Logger.error(f"Unable to back-up preferences file: {type(e)} - {str(e)}")
|
||||
|
||||
# Read the preferences from the newly restored configuration (or else the cached Preferences will override the restored ones)
|
||||
self._application.readPreferencesFromConfiguration()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue