Browse Source

Load setting version from metadata

I'm not really awake today, am I? The functionality happened to still work because of how our real data is structured right now, but the tests still failed. Those are successful now.

Contributes to issue CURA-3427.
Ghostkeeper 7 years ago
parent
commit
55b2392a1d

+ 2 - 2
plugins/VersionUpgrade/VersionUpgrade21to22/VersionUpgrade21to22.py

@@ -1,4 +1,4 @@
-# Copyright (c) 2016 Ultimaker B.V.
+# Copyright (c) 2017 Ultimaker B.V.
 # Cura is released under the terms of the AGPLv3 or higher.
 
 import configparser #To get version numbers from config files.
@@ -250,7 +250,7 @@ class VersionUpgrade21to22(VersionUpgrade):
         parser = configparser.ConfigParser(interpolation = None)
         parser.read_string(serialised)
         format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
-        setting_version = int(parser.get("general", "setting_version", fallback = 0))
+        setting_version = int(parser.get("metadata", "setting_version", fallback = 0))
         return format_version * 1000000 + setting_version
 
     ##  Gets the fallback quality to use for a specific machine-variant-material

+ 2 - 2
plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py

@@ -1,4 +1,4 @@
-# Copyright (c) 2016 Ultimaker B.V.
+# Copyright (c) 2017 Ultimaker B.V.
 # Cura is released under the terms of the AGPLv3 or higher.
 
 import configparser #To get version numbers from config files.
@@ -146,5 +146,5 @@ class VersionUpgrade22to24(VersionUpgrade):
         parser = configparser.ConfigParser(interpolation = None)
         parser.read_string(serialised)
         format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
-        setting_version = int(parser.get("general", "setting_version", fallback = 0))
+        setting_version = int(parser.get("metadata", "setting_version", fallback = 0))
         return format_version * 1000000 + setting_version

+ 1 - 1
plugins/VersionUpgrade/VersionUpgrade25to26/VersionUpgrade25to26.py

@@ -35,7 +35,7 @@ class VersionUpgrade25to26(VersionUpgrade):
         parser = configparser.ConfigParser(interpolation = None)
         parser.read_string(serialised)
         format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
-        setting_version = int(parser.get("general", "setting_version", fallback = 0))
+        setting_version = int(parser.get("metadata", "setting_version", fallback = 0))
         return format_version * 1000000 + setting_version
 
     ##  Upgrades the preferences file from version 2.5 to 2.6.

+ 7 - 0
plugins/VersionUpgrade/VersionUpgrade25to26/tests/TestVersionUpgrade25to26.py

@@ -39,6 +39,13 @@ infill_sparse_density = 42
 version = -20
 """,
         "version": -20000000
+    },
+    {
+        "test_name": "Setting Version",
+        "file_data": """[general]
+version = 1
+[metadata]
+setting_version = 1"""
     }
 ]