summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-09-06 13:56:23 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-09-06 13:56:23 -0400
commitd11ded822cf68d4f33a886e0f97f95a3781e0dc1 (patch)
treebf01cb30263bb7e9d2333ecb9aa5117a797a0334
parentec23eeb9eb273438a59f287f9252e7b1af987fc9 (diff)
display alert for inotify/kqueue errors
-rw-r--r--Assistant/Alert.hs16
-rw-r--r--Assistant/Threads/Watcher.hs5
-rw-r--r--doc/design/assistant/webapp.mdwn4
3 files changed, 20 insertions, 5 deletions
diff --git a/Assistant/Alert.hs b/Assistant/Alert.hs
index 4c4906ef5..296f992bd 100644
--- a/Assistant/Alert.hs
+++ b/Assistant/Alert.hs
@@ -27,7 +27,7 @@ data AlertPriority = Filler | Low | Medium | High | Pinned
{- An alert can have an name, which is used to combine it with other similar
- alerts. -}
-data AlertName = FileAlert TenseChunk | DownloadFailedAlert | SanityCheckFixAlert
+data AlertName = FileAlert TenseChunk | SanityCheckFixAlert | WarningAlert String
deriving (Eq)
{- The first alert is the new alert, the second is an old alert.
@@ -180,6 +180,20 @@ baseActivityAlert = Alert
, alertName = Nothing
}
+warningAlert :: String -> String -> Alert
+warningAlert name msg = Alert
+ { alertClass = Warning
+ , alertHeader = Just $ tenseWords ["warning"]
+ , alertMessageRender = tenseWords
+ , alertData = [UnTensed $ T.pack msg]
+ , alertBlockDisplay = True
+ , alertClosable = True
+ , alertPriority = High
+ , alertIcon = Just "exclamation-sign"
+ , alertCombiner = Just $ dataCombiner (++)
+ , alertName = Just $ WarningAlert name
+ }
+
activityAlert :: Maybe TenseText -> [TenseChunk] -> Alert
activityAlert header dat = baseActivityAlert
{ alertHeader = header
diff --git a/Assistant/Threads/Watcher.hs b/Assistant/Threads/Watcher.hs
index 8ba015b19..89cc98fa4 100644
--- a/Assistant/Threads/Watcher.hs
+++ b/Assistant/Threads/Watcher.hs
@@ -235,10 +235,11 @@ onDelDir threadname dir _ _dstatus _ = do
[Params "--quiet -r --cached --ignore-unmatch --"] [dir]
madeChange dir RmDirChange
-{- Called when there's an error with inotify. -}
+{- Called when there's an error with inotify or kqueue. -}
onErr :: Handler
-onErr _ msg _ _dstatus _ = do
+onErr _ msg _ dstatus _ = do
warning msg
+ void $ liftIO $ addAlert dstatus $ warningAlert "watcher" msg
return Nothing
{- Adds a symlink to the index, without ever accessing the actual symlink
diff --git a/doc/design/assistant/webapp.mdwn b/doc/design/assistant/webapp.mdwn
index eabf8e7f3..9625f007a 100644
--- a/doc/design/assistant/webapp.mdwn
+++ b/doc/design/assistant/webapp.mdwn
@@ -23,8 +23,8 @@ The webapp is a web server that displays a shiny interface.
* there could be a UI to export a file, which would make it be served up
over http by the web app
-* Display any relevant warning messages. One is the `inotify max_user_watches`
- exceeded message.
+* Display the `inotify max_user_watches` exceeded message. **done**
+* Display something sane when kqueue runs out of file descriptors.
* possibly add a desktop file to the top of the repository that can be used
to open the webapp (rather than using the menus). Would be complicated
some by the path to git-annex sometimes needing to be hardcoded and varying