Skip to content

Commit

Permalink
#31: [agent] Only react to event if no other device is connected for …
Browse files Browse the repository at this point in the history
…currect user
  • Loading branch information
mcdope committed Jul 16, 2024
1 parent 256c630 commit 0b2d52b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tools/pamusb-agent
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class HotPlugDevice:

return False

def getWatchedDeviceName(self):
return self.__name

def __scanDevices(self):
for udi in udisksObjectManager.get_objects():
if udi.get_block():
Expand Down Expand Up @@ -240,6 +243,13 @@ def userDeviceThread(user):
resumeTimestamp = datetime.datetime.min

def authChangeCallback(event, deviceName):
nonlocal hpDevs

for otherDeviceThread in hpDevs:
if not otherDeviceThread.getWatchedDeviceName() == deviceName and otherDeviceThread.isDeviceConnected():
logger.info('Device "%s" removed or plugged but another one is connected anyway, ignoring' % deviceName)
return

if event == 'removed':
nonlocal resumeTimestamp
currentTimestamp = datetime.datetime.now()
Expand Down

0 comments on commit 0b2d52b

Please sign in to comment.