mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 12:36:02 +08:00
Use ContainerRegistry.lockFile in Cura package management
Prevent concurrent I/O issues.
This commit is contained in:
parent
cff4dc8a0c
commit
1fb2edace5
@ -48,6 +48,9 @@ class CuraPackageManager(QObject):
|
||||
Logger.log("i", "Package management file %s doesn't exist, do nothing", self._package_management_file_path)
|
||||
return
|
||||
|
||||
# Need to use the file lock here to prevent concurrent I/O from other processes/threads
|
||||
container_registry = self._application.getContainerRegistry()
|
||||
with container_registry.lockFile():
|
||||
with open(self._package_management_file_path, "r", encoding = "utf-8") as f:
|
||||
management_dict = json.load(f, encoding = "utf-8")
|
||||
|
||||
@ -58,6 +61,9 @@ class CuraPackageManager(QObject):
|
||||
Logger.log("i", "Package management file %s is loaded", self._package_management_file_path)
|
||||
|
||||
def _saveManagementData(self) -> None:
|
||||
# Need to use the file lock here to prevent concurrent I/O from other processes/threads
|
||||
container_registry = self._application.getContainerRegistry()
|
||||
with container_registry.lockFile():
|
||||
with open(self._package_management_file_path, "w", encoding = "utf-8") as f:
|
||||
data_dict = {"installed": self._installed_package_dict,
|
||||
"to_remove": list(self._to_remove_package_set),
|
||||
|
Loading…
x
Reference in New Issue
Block a user