Prevent printer from being added twice if it's in cloud and local

CURA-7055
This commit is contained in:
Jaime van Kessel 2020-04-09 16:39:47 +02:00
parent 33b3bb77c3
commit d1337c9e22
No known key found for this signature in database
GPG key ID: 3710727397403C91

View file

@ -120,8 +120,11 @@ class CloudOutputDeviceManager:
for cluster_data in clusters:
device = CloudOutputDevice(self._api, cluster_data)
# Create a machine if we don't already have it. Do not make it the active machine.
meta_data = {self.META_CLUSTER_ID: device.key}
if CuraApplication.getInstance().getMachineManager().getMachine(device.printerType, meta_data) is None:
machine_manager = CuraApplication.getInstance().getMachineManager()
# We only need to add it if it wasn't already added by "local" network or by cloud.
if machine_manager.getMachine(device.printerType, {self.META_CLUSTER_ID: device.key}) is None \
and machine_manager.getMachine(device.printerType, {self.META_NETWORK_KEY: cluster_data.host_name + "*"}) is None: # The host name is part of the network key.
new_devices.append(device)
if not new_devices: