diff options
Diffstat (limited to 'server')
-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)) |