mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Use ContainerRegistry.lockFile in Cura package management
Prevent concurrent I/O issues.
This commit is contained in:
parent
cff4dc8a0c
commit
1fb2edace5
1 changed files with 19 additions and 13 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue