summaryrefslogtreecommitdiff
path: root/Assistant/Threads/MountWatcher.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-07-29 13:22:08 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-07-29 13:22:08 -0400
commit09e77a0cf0ca6e6c76ead584f16818dcf04a94b6 (patch)
tree7750b4b7e48cfe8c3c121e43edb9a3318ea104dd /Assistant/Threads/MountWatcher.hs
parent2dc5697a0ac36fdfe21da79a721db3f086bce041 (diff)
add some alerts
Diffstat (limited to 'Assistant/Threads/MountWatcher.hs')
-rw-r--r--Assistant/Threads/MountWatcher.hs25
1 files changed, 19 insertions, 6 deletions
diff --git a/Assistant/Threads/MountWatcher.hs b/Assistant/Threads/MountWatcher.hs
index 853d96d51..7d0ef5ae4 100644
--- a/Assistant/Threads/MountWatcher.hs
+++ b/Assistant/Threads/MountWatcher.hs
@@ -15,6 +15,7 @@ import Assistant.ThreadedMonad
import Assistant.DaemonStatus
import Assistant.ScanRemotes
import Assistant.Threads.Pusher (pushToRemotes)
+import Assistant.Alert
import qualified Annex
import qualified Git
import Utility.ThreadScheduler
@@ -158,17 +159,29 @@ handleMounts st dstatus scanremotes wasmounted nowmounted = mapM_ (handleMount s
handleMount :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> Mntent -> IO ()
handleMount st dstatus scanremotes mntent = do
- debug thisThread ["detected mount of", mnt_dir mntent]
+ debug thisThread ["detected mount of", dir]
rs <- remotesUnder st dstatus mntent
unless (null rs) $ do
branch <- runThreadState st $ Command.Sync.currentBranch
let nonspecial = filter (Git.repoIsLocal . Remote.repo) rs
- unless (null nonspecial) $ do
- debug thisThread ["pulling from", show nonspecial]
- runThreadState st $ manualPull branch nonspecial
- now <- getCurrentTime
- pushToRemotes thisThread now st Nothing nonspecial
+ unless (null nonspecial) $
+ alertWhile dstatus (syncalert nonspecial) $ do
+ debug thisThread ["syncing with", show nonspecial]
+ runThreadState st $ manualPull branch nonspecial
+ now <- getCurrentTime
+ pushToRemotes thisThread now st Nothing nonspecial
addScanRemotes scanremotes rs
+ where
+ dir = mnt_dir mntent
+ syncalert rs = Alert
+ { alertClass = Activity
+ , alertHeader = Just $ "Syncing with " ++ unwords (map Remote.name rs)
+ , alertMessage = StringAlert $ unwords
+ ["I noticed you plugged in", dir,
+ " -- let's get it in sync!"]
+ , alertBlockDisplay = True
+ }
+
{- Finds remotes located underneath the mount point.
-