display alert for inotify/kqueue errors

This commit is contained in:
Joey Hess 2012-09-06 13:56:23 -04:00
parent ec23eeb9eb
commit d11ded822c
3 changed files with 20 additions and 5 deletions

View file

@ -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 {- An alert can have an name, which is used to combine it with other similar
- alerts. -} - alerts. -}
data AlertName = FileAlert TenseChunk | DownloadFailedAlert | SanityCheckFixAlert data AlertName = FileAlert TenseChunk | SanityCheckFixAlert | WarningAlert String
deriving (Eq) deriving (Eq)
{- The first alert is the new alert, the second is an old alert. {- The first alert is the new alert, the second is an old alert.
@ -180,6 +180,20 @@ baseActivityAlert = Alert
, alertName = Nothing , 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 :: Maybe TenseText -> [TenseChunk] -> Alert
activityAlert header dat = baseActivityAlert activityAlert header dat = baseActivityAlert
{ alertHeader = header { alertHeader = header

View file

@ -235,10 +235,11 @@ onDelDir threadname dir _ _dstatus _ = do
[Params "--quiet -r --cached --ignore-unmatch --"] [dir] [Params "--quiet -r --cached --ignore-unmatch --"] [dir]
madeChange dir RmDirChange madeChange dir RmDirChange
{- Called when there's an error with inotify. -} {- Called when there's an error with inotify or kqueue. -}
onErr :: Handler onErr :: Handler
onErr _ msg _ _dstatus _ = do onErr _ msg _ dstatus _ = do
warning msg warning msg
void $ liftIO $ addAlert dstatus $ warningAlert "watcher" msg
return Nothing return Nothing
{- Adds a symlink to the index, without ever accessing the actual symlink {- Adds a symlink to the index, without ever accessing the actual symlink

View file

@ -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 * there could be a UI to export a file, which would make it be served up
over http by the web app over http by the web app
* Display any relevant warning messages. One is the `inotify max_user_watches` * Display the `inotify max_user_watches` exceeded message. **done**
exceeded message. * 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 * 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 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 some by the path to git-annex sometimes needing to be hardcoded and varying