mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-10 15:25:09 -06:00
Remove invalid quality_changes from the container registry
Fixes CURA-3T
This commit is contained in:
parent
6934e9521f
commit
65377770c4
1 changed files with 28 additions and 0 deletions
|
@ -348,6 +348,34 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||
self._registerSingleExtrusionMachinesExtruderStacks()
|
||||
self._connectUpgradedExtruderStacksToMachines()
|
||||
|
||||
@override(ContainerRegistry)
|
||||
def loadAllMetadata(self) -> None:
|
||||
super().loadAllMetadata()
|
||||
self._cleanUpInvalidQualityChanges()
|
||||
|
||||
def _cleanUpInvalidQualityChanges(self) -> None:
|
||||
# We've seen cases where it was possible for quality_changes to be incorrectly added. This is to ensure that
|
||||
# any such leftovers are purged from the registry.
|
||||
quality_changes = ContainerRegistry.getInstance().findContainersMetadata(type="quality_changes")
|
||||
|
||||
profile_count_by_name = {}
|
||||
|
||||
for quality_change in quality_changes:
|
||||
name = quality_change.get("name")
|
||||
if name == "empty":
|
||||
continue
|
||||
if name not in profile_count_by_name:
|
||||
profile_count_by_name[name] = 0
|
||||
profile_count_by_name[name] += 1
|
||||
|
||||
for profile_name, profile_count in profile_count_by_name.items():
|
||||
if profile_count > 1:
|
||||
continue
|
||||
# Only one profile found, this should not ever be the case, so that profile needs to be removed!
|
||||
Logger.log("d", "Found an invalid quality_changes profile with the name %s. Going to remove that now", profile_name)
|
||||
invalid_quality_changes = ContainerRegistry.getInstance().findContainersMetadata(name=profile_name)
|
||||
self.removeContainer(invalid_quality_changes[0]["id"])
|
||||
|
||||
@override(ContainerRegistry)
|
||||
def _isMetadataValid(self, metadata: Optional[Dict[str, Any]]) -> bool:
|
||||
"""Check if the metadata for a container is okay before adding it.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue