mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 18:39:07 +08:00
Check all subdirs in data storage dir for package removal
This commit is contained in:
parent
096f304aef
commit
7ee085fe50
@ -245,22 +245,17 @@ class CuraPackageManager(QObject):
|
|||||||
|
|
||||||
# Removes everything associated with the given package ID.
|
# Removes everything associated with the given package ID.
|
||||||
def _purgePackage(self, package_id: str) -> None:
|
def _purgePackage(self, package_id: str) -> None:
|
||||||
# Get all folders that need to be checked for installed packages, including:
|
# Iterate through all directories in the data storage directory and look for sub-directories that belong to
|
||||||
# - materials
|
# the package we need to remove, that is the sub-dirs with the package_id as names, and remove all those dirs.
|
||||||
# - qualities
|
data_storage_dir = os.path.abspath(Resources.getDataStoragePath())
|
||||||
# - plugins
|
|
||||||
from cura.CuraApplication import CuraApplication
|
|
||||||
dirs_to_check = [
|
|
||||||
Resources.getStoragePath(CuraApplication.ResourceTypes.MaterialInstanceContainer),
|
|
||||||
Resources.getStoragePath(CuraApplication.ResourceTypes.QualityInstanceContainer),
|
|
||||||
os.path.join(os.path.abspath(Resources.getDataStoragePath()), "plugins"),
|
|
||||||
]
|
|
||||||
|
|
||||||
for root_dir in dirs_to_check:
|
for root, dir_names, _ in os.walk(data_storage_dir):
|
||||||
package_dir = os.path.join(root_dir, package_id)
|
for dir_name in dir_names:
|
||||||
if os.path.exists(package_dir):
|
package_dir = os.path.join(root, dir_name, package_id)
|
||||||
Logger.log("i", "Removing '%s' for package [%s]", package_dir, package_id)
|
if os.path.exists(package_dir):
|
||||||
|
Logger.log("i", "Removing '%s' for package [%s]", package_dir, package_id)
|
||||||
shutil.rmtree(package_dir)
|
shutil.rmtree(package_dir)
|
||||||
|
break
|
||||||
|
|
||||||
# Installs all files associated with the given package.
|
# Installs all files associated with the given package.
|
||||||
def _installPackage(self, installation_package_data: dict):
|
def _installPackage(self, installation_package_data: dict):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user