From 5a919f01d178b8d6c0bb3b0b40d8c7fea7ff7ac6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 9 Dec 2016 16:27:20 -0400 Subject: make tor hidden service work when directory watching is not available Avoid crashing when built w/o inotify.. --- Annex/ChangedRefs.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Annex') diff --git a/Annex/ChangedRefs.hs b/Annex/ChangedRefs.hs index 0dc82d3b3..1f2372c04 100644 --- a/Annex/ChangedRefs.hs +++ b/Annex/ChangedRefs.hs @@ -71,7 +71,7 @@ stopWatchingChangedRefs h@(ChangedRefsHandle wh chan) = do atomically $ closeTBMChan chan drainChangedRefs h -watchChangedRefs :: Annex ChangedRefsHandle +watchChangedRefs :: Annex (Maybe ChangedRefsHandle) watchChangedRefs = do -- This channel is used to accumulate notifications, -- because the DirWatcher might have multiple threads that find @@ -90,8 +90,11 @@ watchChangedRefs = do , modifyHook = notifyhook } - h <- liftIO $ watchDir refdir (const False) True hooks id - return $ ChangedRefsHandle h chan + if canWatch + then do + h <- liftIO $ watchDir refdir (const False) True hooks id + return $ Just $ ChangedRefsHandle h chan + else return Nothing notifyHook :: TBMChan Git.Sha -> FilePath -> Maybe FileStatus -> IO () notifyHook chan reffile _ -- cgit v1.2.3