Cura directory may be empty

Contributes to issue CURA-7024.
This commit is contained in:
Ghostkeeper 2020-02-04 14:11:41 +01:00
parent 94e97aff37
commit bb73831889
No known key found for this signature in database
GPG key ID: 37E2020986774393

View file

@ -30,12 +30,18 @@ class VersionUpgrade44to45(VersionUpgrade):
In this case the plug-in will also check for stacks that need to be In this case the plug-in will also check for stacks that need to be
deleted. deleted.
""" """
# Only delete hidden stacks when upgrading from version 4.4. Not 4.3 or 4.5, just when you're starting out from 4.4.
# If you're starting from an earlier version, you can't have had the bug that produces too many hidden stacks (https://github.com/Ultimaker/Cura/issues/6731).
# If you're starting from a later version, the bug was already fixed.
data_storage_root = os.path.dirname(Resources.getDataStoragePath()) data_storage_root = os.path.dirname(Resources.getDataStoragePath())
folders = os.listdir(data_storage_root) # All version folders. folders = os.listdir(data_storage_root) # All version folders.
folders = filter(lambda p: re.fullmatch(r"\d+\.\d+", p), folders) # Only folders with a correct version number as name. folders = set(filter(lambda p: re.fullmatch(r"\d+\.\d+", p), folders)) # Only folders with a correct version number as name.
latest_version = max(list(folders), key = Version) # Sort them by semantic version numbering. folders.difference_update({os.path.basename(Resources.getDataStoragePath())}) # Remove current version from candidates (since the folder was just copied).
if latest_version == "4.4": if folders:
self.removeHiddenStacks() latest_version = max(folders, key = Version) # Sort them by semantic version numbering.
if latest_version == "4.4":
self.removeHiddenStacks()
def removeHiddenStacks(self) -> None: def removeHiddenStacks(self) -> None:
""" """