Commits

Anonymous committed ef14b0d

Create directory if needed in create function.

Comments (0)

Files changed (1)

Data/FileStore/Git.hs

 import Codec.Binary.UTF8.String (decodeString)
 import Data.Char (chr)
 import Control.Monad (liftM)
-import System.FilePath ((</>))
-import System.Directory (doesFileExist, removeFile)
+import System.FilePath ((</>), takeDirectory)
+import System.Directory (doesFileExist, removeFile, createDirectoryIfMissing)
 
 gitFileStore :: FilePath   -- ^ directory containing the git repo
              -> FileStore
   if exists
      then return $ Left $ AlreadyExists
      else do
+       let dir' = takeDirectory filename
+       createDirectoryIfMissing True dir'
        B.writeFile filename $ toByteString contents
        (statusAdd, errAdd, _) <- runGitCommand repo "add" [name]
        if statusAdd == ExitSuccess