summaryrefslogtreecommitdiff
path: root/Command/NotifyChanges.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-12-09 16:27:20 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-12-09 16:40:47 -0400
commit5a919f01d178b8d6c0bb3b0b40d8c7fea7ff7ac6 (patch)
tree3b5da82b53b9550c1c6f637aae981d2252accc0c /Command/NotifyChanges.hs
parent3d6a48572d1b626ef68785d3e7ed400b4016d9e5 (diff)
make tor hidden service work when directory watching is not available
Avoid crashing when built w/o inotify..
Diffstat (limited to 'Command/NotifyChanges.hs')
-rw-r--r--Command/NotifyChanges.hs25
1 files changed, 13 insertions, 12 deletions
diff --git a/Command/NotifyChanges.hs b/Command/NotifyChanges.hs
index 92c70f05e..27db8ad82 100644
--- a/Command/NotifyChanges.hs
+++ b/Command/NotifyChanges.hs
@@ -24,18 +24,19 @@ seek :: CmdParams -> CommandSeek
seek = withNothing start
start :: CommandStart
-start = do
- h <- watchChangedRefs
-
- -- No messages need to be received from the caller,
- -- but when it closes the connection, notice and terminate.
- let receiver = forever $ void $ getProtocolLine stdin
- let sender = forever $ send . CHANGED =<< waitChangedRefs h
-
- liftIO $ send READY
- void $ liftIO $ concurrently sender receiver
- liftIO $ stopWatchingChangedRefs h
- stop
+start = go =<< watchChangedRefs
+ where
+ go (Just h) = do
+ -- No messages need to be received from the caller,
+ -- but when it closes the connection, notice and terminate.
+ let receiver = forever $ void $ getProtocolLine stdin
+ let sender = forever $ send . CHANGED =<< waitChangedRefs h
+
+ liftIO $ send READY
+ void $ liftIO $ concurrently sender receiver
+ liftIO $ stopWatchingChangedRefs h
+ stop
+ go Nothing = stop
send :: Notification -> IO ()
send n = do