From 1dcb2b58aa3afa6cd5be7c37f71cf42ab8545d24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Tue, 4 Feb 2025 21:11:22 +0100 Subject: Use 'temporary' package instead of 'mktemp' command Changelog: Fix that empty temorary dir was not deleted in some cases --- minici.cabal | 1 + src/Job.hs | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/minici.cabal b/minici.cabal index 536083d..560282b 100644 --- a/minici.cabal +++ b/minici.cabal @@ -97,6 +97,7 @@ executable minici process ^>= { 1.6 }, stm ^>= { 2.5 }, template-haskell ^>= { 2.17, 2.18, 2.19, 2.20, 2.21, 2.22, 2.23 }, + temporary ^>= { 1.3 }, text ^>= { 1.2, 2.0, 2.1 }, th-compat ^>= { 0.1 }, unix ^>= { 2.7.3, 2.8.6 }, diff --git a/src/Job.hs b/src/Job.hs index 71da738..cf7dde8 100644 --- a/src/Job.hs +++ b/src/Job.hs @@ -31,6 +31,7 @@ import System.Directory import System.Exit import System.FilePath import System.IO +import System.IO.Temp import System.Posix.Signals import System.Process @@ -280,10 +281,7 @@ updateStatusFile path outVar = void $ liftIO $ forkIO $ loop Nothing prepareJob :: (MonadIO m, MonadMask m, MonadFail m) => FilePath -> Commit -> Job -> (FilePath -> FilePath -> m a) -> m a prepareJob dir commit job inner = do - [checkoutPath] <- fmap lines $ liftIO $ - readProcess "mktemp" ["-d", "-t", "minici.XXXXXXXXXX"] "" - - flip finally (liftIO $ removeDirectoryRecursive checkoutPath) $ do + withSystemTempDirectory "minici" $ \checkoutPath -> do checkoutAt commit checkoutPath tid <- getTreeId commit -- cgit v1.2.3