assistant: Use udisks2 dbus events to detect when disks are mounted, instead of relying on gnome/kde stuff that is not stable.

This commit is contained in:
Joey Hess 2016-01-22 16:50:08 -04:00
parent 93806b0c8c
commit 8c3d302532
Failed to extract signature
4 changed files with 27 additions and 31 deletions

View file

@ -48,7 +48,7 @@ mountWatcherThread urlrenderer = namedThread "MountWatcher" $
dbusThread :: UrlRenderer -> Assistant ()
dbusThread urlrenderer = do
runclient <- asIO1 go
r <- liftIO $ E.try $ runClient getSessionAddress runclient
r <- liftIO $ E.try $ runClient getSystemAddress runclient
either onerr (const noop) r
where
go client = ifM (checkMountMonitor client)
@ -71,11 +71,6 @@ dbusThread urlrenderer = do
)
onerr :: E.SomeException -> Assistant ()
onerr e = do
{- If the session dbus fails, the user probably
- logged out of their desktop. Even if they log
- back in, we won't have access to the dbus
- session key, so polling is the best that can be
- done in this situation. -}
liftAnnex $
warning $ "dbus failed; falling back to mtab polling (" ++ show e ++ ")"
pollingThread urlrenderer
@ -95,12 +90,9 @@ checkMountMonitor client = do
]
return True
where
startableservices = [gvfsnew, gvfs, gvfsgdu]
usableservices = startableservices ++ [kde]
gvfs = "org.gtk.Private.UDisks2VolumeMonitor"
gvfsnew = "org.gtk.vfs.UDisks2VolumeMonitor"
gvfsgdu = "org.gtk.Private.GduVolumeMonitor"
kde = "org.kde.DeviceNotifications"
startableservices = [udisks2]
usableservices = startableservices
udisks2 = "org.freedesktop.UDisks2"
startOneService :: Client -> [ServiceName] -> Assistant Bool
startOneService _ [] = return False
@ -119,27 +111,18 @@ startOneService client (x:xs) = do
{- Filter matching events recieved when drives are mounted and unmounted. -}
mountChanged :: [MatchRule]
mountChanged = [gvfs True, gvfs False, kde, kdefallback]
mountChanged = [udisks2mount, udisks2umount]
where
{- gvfs reliably generates this event whenever a
- drive is mounted/unmounted, whether automatically, or manually -}
gvfs mount = matchAny
{ matchInterface = Just "org.gtk.Private.RemoteVolumeMonitor"
, matchMember = Just $ if mount then "MountAdded" else "MountRemoved"
udisks2mount = matchAny
{ matchPath = Just "/org/freedesktop/UDisks2"
, matchInterface = Just "org.freedesktop.DBus.ObjectManager"
, matchMember = Just "InterfacesAdded"
}
{- This event fires when KDE prompts the user what to do with a drive,
- but maybe not at other times. And it's not received -}
kde = matchAny
{ matchInterface = Just "org.kde.Solid.Device"
, matchMember = Just "setupDone"
udisks2umount = matchAny
{ matchPath = Just "/org/freedesktop/UDisks2"
, matchInterface = Just "org.freedesktop.DBus.ObjectManager"
, matchMember = Just "InterfacesRemoved"
}
{- This event may not be closely related to mounting a drive, but it's
- observed reliably when a drive gets mounted or unmounted. -}
kdefallback = matchAny
{ matchInterface = Just "org.kde.KDirNotify"
, matchMember = Just "enteredDirectory"
}
#endif
pollingThread :: UrlRenderer -> Assistant ()

3
debian/changelog vendored
View file

@ -13,7 +13,8 @@ git-annex (6.20160115) UNRELEASED; urgency=medium
* registerurl: Check if a remote claims the url, same as addurl does.
* Bug fix: Git config settings passed to git-annex -c did not always take
effect.
* assistant: Added new name used for udisks2 dbus service in gnome 3.18.
* assistant: Use udisks2 dbus events to detect when disks are mounted,
instead of relying on gnome/kde stuff that is not stable.
-- Joey Hess <id@joeyh.name> Fri, 15 Jan 2016 14:05:01 -0400

View file

@ -178,3 +178,5 @@ node /org/gtk/Private/RemoteVolumeMonitor {
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
Works fine in general.
> [[fixed|done]] --[[Joey]]

View file

@ -0,0 +1,10 @@
[[!comment format=mdwn
username="joey"
subject="""comment 3"""
date="2016-01-22T20:10:01Z"
content="""
Thanks for the info.
I think I was having difficulty matching on the udisks2 signals before, due
to how they're structured, but I found a way now.
"""]]