From 671d401b7b3d5a3d0733a84fbdebca355bd43176 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 21 Jun 2015 20:33:21 +0200 Subject: locking in adjmix --- adjmix/Adjmix.hs | 7 ++++++- trivmix.cabal | 3 ++- trivmix.nix | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/adjmix/Adjmix.hs b/adjmix/Adjmix.hs index 645ac6a..94416ac 100644 --- a/adjmix/Adjmix.hs +++ b/adjmix/Adjmix.hs @@ -3,6 +3,7 @@ import Options.Applicative import System.FilePath +import System.FileLock import Data.Char @@ -20,6 +21,7 @@ optionParser = Options <> metavar "DIRECTORY" <> value "/dev/shm/mix" <> showDefault + <> help "Base directory" ) <*> strOption ( long "target" <> short 't' @@ -35,16 +37,19 @@ optionParser = Options <*> ( ( Set <$> option auto ( long "set" <> short 'o' <> metavar "LEVEL" + <> help "Overwrite the current level" ) ) <|> ( Add <$> option auto ( long "add" <> short 'a' <> metavar "LEVEL" + <> help "Add to the current level" ) ) <|> ( Sub <$> option auto ( long "sub" <> short 's' <> metavar "LEVEL" + <> help "Subtract from the current level" ) ) ) @@ -59,7 +64,7 @@ main = execParser opts >>= adjmix ) adjmix :: Options -> IO () -adjmix Options{..} = do +adjmix Options{..} = withFileLock levelFile' Exclusive $ const $ do oldLevel <- readFile levelFile' >>= readIO . stripSpace let newLevel = oldLevel `doAdjustment` adjustment diff --git a/trivmix.cabal b/trivmix.cabal index 803c640..54aad76 100644 --- a/trivmix.cabal +++ b/trivmix.cabal @@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: trivmix -version: 2.5.2 +version: 2.5.3 -- synopsis: -- description: license: PublicDomain @@ -48,6 +48,7 @@ executable adjmix build-depends: base >=4.7 && <4.8 , optparse-applicative >=0.11 && <1 , filepath >=1.3 && <2 + , filelock >=0.1 && <1 , trivmix hs-source-dirs: adjmix default-language: Haskell2010 diff --git a/trivmix.nix b/trivmix.nix index 298174b..d29bb48 100644 --- a/trivmix.nix +++ b/trivmix.nix @@ -6,7 +6,7 @@ cabal.mkDerivation (self: { pname = "trivmix"; - version = "2.5.2"; + version = "2.5.3"; src = ./.; isLibrary = true; isExecutable = true; -- cgit v1.2.3