From 58369822fce3c8baedf945ec5cf64fd4c67ccddf Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 16 Mar 2021 16:36:01 +0100 Subject: [PATCH] Clean up invalid quality changes robust to asynchronous changes It's possible that a profile is no longer in the registry by the time it gets to that point in the list if this clean-up is triggered by the very action of deleting a profile. Fixes Sentry issue CURA-1T5. --- cura/Settings/CuraContainerRegistry.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cura/Settings/CuraContainerRegistry.py b/cura/Settings/CuraContainerRegistry.py index 00a0eedbf0..7e6c3f5d20 100644 --- a/cura/Settings/CuraContainerRegistry.py +++ b/cura/Settings/CuraContainerRegistry.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Ultimaker B.V. +# Copyright (c) 2021 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. import os @@ -381,9 +381,10 @@ class CuraContainerRegistry(ContainerRegistry): 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"]) + if invalid_quality_changes: + Logger.log("d", "Found an invalid quality_changes profile with the name %s. Going to remove that now", profile_name) + self.removeContainer(invalid_quality_changes[0]["id"]) @override(ContainerRegistry) def _isMetadataValid(self, metadata: Optional[Dict[str, Any]]) -> bool: