diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-25 18:46:25 +0000 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-25 18:46:25 +0000 |
| commit | 36bc432fc0f8ae46c7ff0de162ee275d25f12e3a (patch) | |
| tree | d4235521178476d0bbdb3aee45d9ee218f271f29 | |
| parent | c5ac4dabf4a2a0d3737c95ff683fefaabe521efa (diff) | |
| download | thermoprint-36bc432fc0f8ae46c7ff0de162ee275d25f12e3a.tar thermoprint-36bc432fc0f8ae46c7ff0de162ee275d25f12e3a.tar.gz thermoprint-36bc432fc0f8ae46c7ff0de162ee275d25f12e3a.tar.bz2 thermoprint-36bc432fc0f8ae46c7ff0de162ee275d25f12e3a.tar.xz thermoprint-36bc432fc0f8ae46c7ff0de162ee275d25f12e3a.zip | |
more logging
| -rw-r--r-- | server/src/Thermoprint/Server/API.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/server/src/Thermoprint/Server/API.hs b/server/src/Thermoprint/Server/API.hs index 2adca3c..3c8fefe 100644 --- a/server/src/Thermoprint/Server/API.hs +++ b/server/src/Thermoprint/Server/API.hs | |||
| @@ -23,6 +23,8 @@ import qualified Data.Sequence as Seq | |||
| 23 | import Data.Map (Map) | 23 | import Data.Map (Map) |
| 24 | import qualified Data.Map as Map | 24 | import qualified Data.Map as Map |
| 25 | 25 | ||
| 26 | import qualified Data.Text as T | ||
| 27 | |||
| 26 | import Servant | 28 | import Servant |
| 27 | import Servant.Server | 29 | import Servant.Server |
| 28 | import Servant.Server.Internal.Enter | 30 | import Servant.Server.Internal.Enter |
| @@ -144,11 +146,13 @@ abortJob jobId = do | |||
| 144 | printerIds <- asks (Map.keys . printers) | 146 | printerIds <- asks (Map.keys . printers) |
| 145 | found <- fmap or . forM printerIds $ \pId -> do | 147 | found <- fmap or . forM printerIds $ \pId -> do |
| 146 | (pId', p) <- lookupPrinter $ Just pId | 148 | (pId', p) <- lookupPrinter $ Just pId |
| 147 | liftIO . atomically $ do | 149 | found <- liftIO . atomically $ do |
| 148 | current@(Queue pending _ _) <- readTVar $ queue p | 150 | current@(Queue pending _ _) <- readTVar $ queue p |
| 149 | let filtered = Seq.filter (/= castId jobId) pending | 151 | let filtered = Seq.filter (/= castId jobId) pending |
| 150 | writeTVar (queue p) $ current { pending = filtered } | 152 | writeTVar (queue p) $ current { pending = filtered } |
| 151 | return . not $ ((==) `on` length) pending filtered | 153 | return . not $ ((==) `on` length) pending filtered |
| 154 | when found . lift . $(logInfo) $ "Removed " <> (T.pack $ show (castId jobId :: Integer)) <> " from " <> (T.pack . show $ pId') | ||
| 155 | return found | ||
| 152 | when (not found) $ left err404 | 156 | when (not found) $ left err404 |
| 153 | 157 | ||
| 154 | listDrafts :: Handler (Map API.DraftId (Maybe DraftTitle)) | 158 | listDrafts :: Handler (Map API.DraftId (Maybe DraftTitle)) |
