tweak types so the webapp can run without a threadstate when outside an annex
This commit is contained in:
parent
e9d9d9d5ea
commit
b9b0097876
4 changed files with 14 additions and 6 deletions
|
@ -30,7 +30,7 @@ staticFiles "static"
|
|||
mkYesodData "WebApp" $(parseRoutesFile "Assistant/WebApp/routes")
|
||||
|
||||
data WebApp = WebApp
|
||||
{ threadState :: ThreadState
|
||||
{ threadState :: Maybe ThreadState
|
||||
, daemonStatus :: DaemonStatusHandle
|
||||
, transferQueue :: TransferQueue
|
||||
, secretToken :: Text
|
||||
|
@ -104,6 +104,16 @@ modifyWebAppState a = go =<< webAppState <$> getYesod
|
|||
v <- takeTMVar s
|
||||
putTMVar s $ a v
|
||||
|
||||
{- Runs an Annex action from the webapp.
|
||||
-
|
||||
- When the webapp is run outside a git-annex repository, the fallback
|
||||
- value is returned.
|
||||
-}
|
||||
runAnnex :: forall sub a. a -> Annex a -> GHandler sub WebApp a
|
||||
runAnnex fallback a = maybe (return fallback) go =<< threadState <$> getYesod
|
||||
where
|
||||
go st = liftIO $ runThreadState st a
|
||||
|
||||
waitNotifier :: forall sub. (DaemonStatus -> NotificationBroadcaster) -> NotificationId -> GHandler sub WebApp ()
|
||||
waitNotifier selector nid = do
|
||||
notifier <- getNotifier selector
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue