1. John Lenz
  2. filestore

Commits

j...@berkeley.edu  committed ef14b0d

Create directory if needed in create function.

  • Participants
  • Parent commits b7f7379
  • Branches default

Comments (0)

Files changed (1)

File Data/FileStore/Git.hs

View file
 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