From 6998f6b3a6051d555c93f3abeb3a869c7c23fed4 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 22 May 2006 12:51:39 -0400 Subject: [PATCH] Ensure keys exist or don't exist before using them or adding them, respectively --- sugar/p2p/Group.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sugar/p2p/Group.py b/sugar/p2p/Group.py index 43b632e9..48e6a290 100644 --- a/sugar/p2p/Group.py +++ b/sugar/p2p/Group.py @@ -69,12 +69,14 @@ class LocalGroup(Group): def add_service(self, service): sid = (service.get_name(), service.get_type()) - self._services[sid] = service - self._notify_service_added(service) + if not self._services.has_key(sid): + self._services[sid] = service + self._notify_service_added(service) def remove_service(self, service_id): - self._notify_service_removed(service_id) - del self._services[service_id] + if self._services.has_key(service_id): + self._notify_service_removed(service_id) + del self._services[service_id] def join(self): self._owner.register()