From: Andrej Shadura <andrew.shadura@collabora.co.uk>
Date: Sat, 28 Dec 2024 14:27:11 +0100
Subject: Handle missing keys in cons

---
 syncthing_gtk/daemon.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/syncthing_gtk/daemon.py b/syncthing_gtk/daemon.py
index bd9ea50..df0852a 100644
--- a/syncthing_gtk/daemon.py
+++ b/syncthing_gtk/daemon.py
@@ -501,7 +501,7 @@ class Daemon(GObject.GObject, TimerManager):
         # Use my own device for totals, if it is already known
         # It it is not known, just skip totals for now
         if self._my_id is not None:
-            cons[self._my_id].update(data["total"])
+            cons[self._my_id] = cons.get(self._my_id, {}) | data["total"]
 
         for id in cons:
             # Load device data
@@ -526,13 +526,13 @@ class Daemon(GObject.GObject, TimerManager):
             if "clientVersion" in cons[id] and cons[id]["clientVersion"] != "":
                 device_data["clientVersion"] = cons[id]["clientVersion"]
 
-            if cons[id]["paused"]:
+            if cons[id].get("paused", False):
                 # Send "device-paused" signal if device needed
                 device_data["connected"] = False
                 self.emit("device-paused", nid)
             else:
                 # Send "device-connected" signal, if device was disconnected until now
-                if cons[id]["connected"]:
+                if cons[id].get("connected", False):
                     if not device_data["connected"] and nid != self._my_id:
                         device_data["connected"] = True
                         self.emit("device-connected", nid)
