mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-15 21:26:06 +08:00
Make Backup._application private
This commit is contained in:
parent
6e2f7e72b6
commit
c04c7654c1
@ -30,7 +30,7 @@ class Backup:
|
|||||||
catalog = i18nCatalog("cura")
|
catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
def __init__(self, application: "CuraApplication", zip_file: bytes = None, meta_data: Dict[str, str] = None) -> None:
|
def __init__(self, application: "CuraApplication", zip_file: bytes = None, meta_data: Dict[str, str] = None) -> None:
|
||||||
self.application = application
|
self._application = application
|
||||||
self.zip_file = zip_file # type: Optional[bytes]
|
self.zip_file = zip_file # type: Optional[bytes]
|
||||||
self.meta_data = meta_data # type: Optional[Dict[str, str]]
|
self.meta_data = meta_data # type: Optional[Dict[str, str]]
|
||||||
|
|
||||||
@ -42,12 +42,12 @@ class Backup:
|
|||||||
Logger.log("d", "Creating backup for Cura %s, using folder %s", cura_release, version_data_dir)
|
Logger.log("d", "Creating backup for Cura %s, using folder %s", cura_release, version_data_dir)
|
||||||
|
|
||||||
# Ensure all current settings are saved.
|
# Ensure all current settings are saved.
|
||||||
self.application.saveSettings()
|
self._application.saveSettings()
|
||||||
|
|
||||||
# We copy the preferences file to the user data directory in Linux as it's in a different location there.
|
# We copy the preferences file to the user data directory in Linux as it's in a different location there.
|
||||||
# When restoring a backup on Linux, we move it back.
|
# When restoring a backup on Linux, we move it back.
|
||||||
if Platform.isLinux():
|
if Platform.isLinux():
|
||||||
preferences_file_name = self.application.getApplicationName()
|
preferences_file_name = self._application.getApplicationName()
|
||||||
preferences_file = Resources.getPath(Resources.Preferences, "{}.cfg".format(preferences_file_name))
|
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))
|
backup_preferences_file = os.path.join(version_data_dir, "{}.cfg".format(preferences_file_name))
|
||||||
Logger.log("d", "Copying preferences file from %s to %s", preferences_file, backup_preferences_file)
|
Logger.log("d", "Copying preferences file from %s to %s", preferences_file, backup_preferences_file)
|
||||||
@ -113,7 +113,7 @@ class Backup:
|
|||||||
"Tried to restore a Cura backup without having proper data or meta data."))
|
"Tried to restore a Cura backup without having proper data or meta data."))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
current_version = self.application.getVersion()
|
current_version = self._application.getVersion()
|
||||||
version_to_restore = self.meta_data.get("cura_release", "master")
|
version_to_restore = self.meta_data.get("cura_release", "master")
|
||||||
if current_version != version_to_restore:
|
if current_version != version_to_restore:
|
||||||
# Cannot restore version older or newer than current because settings might have changed.
|
# Cannot restore version older or newer than current because settings might have changed.
|
||||||
@ -129,7 +129,7 @@ class Backup:
|
|||||||
|
|
||||||
# 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.
|
||||||
if Platform.isLinux():
|
if Platform.isLinux():
|
||||||
preferences_file_name = self.application.getApplicationName()
|
preferences_file_name = self._application.getApplicationName()
|
||||||
preferences_file = Resources.getPath(Resources.Preferences, "{}.cfg".format(preferences_file_name))
|
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))
|
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)
|
Logger.log("d", "Moving preferences file from %s to %s", backup_preferences_file, preferences_file)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user