From 3f85ac264c7b673c3db5fb0a83509136098aac61 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 21 Sep 2016 17:34:13 +0200 Subject: [PATCH] Properly serialise the machine instance name Otherwise we get spaces and unescaped plusses in the file name of the user profile. Contributes to issue CURA-844. --- .../VersionUpgrade/VersionUpgrade21to22/MachineInstance.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py b/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py index 71646b45f7..222af84d3a 100644 --- a/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py +++ b/plugins/VersionUpgrade/VersionUpgrade21to22/MachineInstance.py @@ -8,6 +8,7 @@ import UM.Resources #To get the config storage path. import configparser #To read config files. import io #To write config files to strings as if they were files. import os.path #To get the path to write new user profiles to. +import urllib #To serialise the user container file name properly. ## Creates a new machine instance instance by parsing a serialised machine # instance in version 1 of the file format. @@ -110,12 +111,12 @@ class MachineInstance: version_upgrade_manager = UM.VersionUpgradeManager.VersionUpgradeManager.getInstance() user_storage = os.path.join(UM.Resources.getDataStoragePath(), next(iter(version_upgrade_manager.getStoragePaths("user")))) - user_profile_file = os.path.join(user_storage, self._name + "_current_settings.inst.cfg") + user_profile_file = os.path.join(user_storage, urllib.parse.quote_plus(self._name) + "_current_settings.inst.cfg") if not os.path.exists(user_storage): os.makedirs(user_storage) with open(user_profile_file, "w") as file_handle: user_profile.write(file_handle) - version_upgrade_manager.upgradeExtraFile(user_storage, self._name + "_current_settings", "user") + version_upgrade_manager.upgradeExtraFile(user_storage, urllib.parse.quote_plus(self._name), "user") containers = [ self._name + "_current_settings", #The current profile doesn't know the definition ID when it was upgraded, only the instance ID, so it will be invalid. Sorry, your current settings are lost now.