Commits

Byron Clark  committed 177d381

More complete handling of the last state storage.

refs issue 1

  • Participants
  • Parent commits 9819b69

Comments (0)

Files changed (1)

File udiskie/mount.py

         self.bus.add_signal_receiver(self.device_added,
                                      signal_name='DeviceAdded',
                                      bus_name='org.freedesktop.UDisks')
+        self.bus.add_signal_receiver(self.device_removed,
+                                     signal_name='DeviceRemoved',
+                                     bus_name='org.freedesktop.UDisks')
         self.bus.add_signal_receiver(self.device_changed,
                                      signal_name='DeviceChanged',
                                      bus_name='org.freedesktop.UDisks')
 
     def device_added(self, device):
         self.log.debug('device added: %s' % (device,))
+        # Since the device just appeared we don't want the old state.
+        if device in self.last_device_state:
+            del self.last_device_state[device]
         self._mount_device(udiskie.device.Device(self.bus, device))
 
+    def device_removed(self, device):
+        self.log.debug('device removed: %s' % (device,))
+        if device in self.last_device_state:
+            del self.last_device_state[device]
+
     def device_changed(self, device):
         self.log.debug('device changed: %s' % (device,))
         last_state = self.last_device_state.get(device)