diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2017-03-12 16:36:26 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2017-03-12 16:36:26 -0700 |
commit | 43c26a5e18650730deaabbf8d7164bbf83c4ad67 (patch) | |
tree | 116b9913c6f31721b8b9363537304c664ad18082 | |
parent | 0c701f1455e3a92d8ee1da6c33a9c24087093ca7 (diff) | |
download | sscan-43c26a5e18650730deaabbf8d7164bbf83c4ad67.tar.gz |
don't exit until all ocrmypdf threads have completed
-rw-r--r-- | Main.hs | 35 | ||||
-rw-r--r-- | sscan.cabal | 1 |
2 files changed, 19 insertions, 17 deletions
@@ -23,20 +23,20 @@ along with sscan. If not, see <http://www.gnu.org/licenses/>. {-# LANGUAGE OverloadedStrings #-} -import Control.Concurrent (forkIO) -import Control.Monad (unless, void, when) -import Data.Time.Clock.POSIX (getPOSIXTime, posixSecondsToUTCTime) -import Data.Time.Format (defaultTimeLocale, formatTime, - iso8601DateFormat) -import Lens.Micro ((^.)) -import System.Directory (getHomeDirectory, removeFile, - renamePath, withCurrentDirectory) -import System.Exit (ExitCode (..)) -import System.FilePath ((<.>), (</>)) -import System.IO (IOMode (WriteMode), hClose, - hGetContents, hPutStr, openFile, - withBinaryFile, withFile) -import System.IO.Temp (withSystemTempDirectory) +import Control.Concurrent.Async (concurrently_) +import Control.Monad (unless, void, when) +import Data.Time.Clock.POSIX (getPOSIXTime, posixSecondsToUTCTime) +import Data.Time.Format (defaultTimeLocale, formatTime, + iso8601DateFormat) +import Lens.Micro ((^.)) +import System.Directory (getHomeDirectory, removeFile, + renamePath, withCurrentDirectory) +import System.Exit (ExitCode (..)) +import System.FilePath ((<.>), (</>)) +import System.IO (IOMode (WriteMode), hClose, + hGetContents, hPutStr, openFile, + withBinaryFile, withFile) +import System.IO.Temp (withSystemTempDirectory) import System.Process import Types.State @@ -201,11 +201,12 @@ processCommand st = case st^.stScanSess of then presentUI (incrementPages st) else newSession FinalPage -> scanPage st dir - >> finaliseSession (incrementPages st) dir >> newSession - Finalise -> finaliseSession st dir >> newSession + >> finaliseSession (incrementPages st) dir + Finalise -> finaliseSession st dir where newSession = presentUI $ resetScanSess st - finaliseSession st' dir = forkIO $ processScanSessDir st' dir + finaliseSession st' dir = + concurrently_ (processScanSessDir st' dir) newSession presentUI :: St -> IO () presentUI st = runTheApp st >>= processCommand diff --git a/sscan.cabal b/sscan.cabal index 76978c6..afa5ba6 100644 --- a/sscan.cabal +++ b/sscan.cabal @@ -31,6 +31,7 @@ executable sscan , temporary >= 1.2 && <1.3 , process >= 1.4 && <1.5 , time >=1.6 && <1.7 + , async >=2.1 && <2.2 -- hs-source-dirs: default-language: Haskell2010 other-modules: |