create journal directory in withJournalHandle
Fixes a crash by git-annex repair when .git/annex/journal/ does not exist. Normally the journal directory is created before withJournalHandle gets run, but git-annex repair can be run in a situation where it does not exist.
This commit is contained in:
parent
aa8be9850a
commit
928b2a4839
4 changed files with 29 additions and 2 deletions
|
@ -230,8 +230,13 @@ getJournalledFilesStale getjournaldir = do
|
|||
{- Directory handle open on a journal directory. -}
|
||||
withJournalHandle :: (Git.Repo -> RawFilePath) -> (DirectoryHandle -> IO a) -> Annex a
|
||||
withJournalHandle getjournaldir a = do
|
||||
d <- fromRawFilePath <$> fromRepo getjournaldir
|
||||
bracketIO (openDirectory d) closeDirectory (liftIO . a)
|
||||
d <- fromRepo getjournaldir
|
||||
bracket (opendir d) (liftIO . closeDirectory) (liftIO . a)
|
||||
where
|
||||
-- avoid overhead of creating the journal directory when it already
|
||||
-- exists
|
||||
opendir d = liftIO (openDirectory (fromRawFilePath d))
|
||||
`catchIO` (const (createAnnexDirectory d >> opendir d))
|
||||
|
||||
{- Checks if there are changes in the journal. -}
|
||||
journalDirty :: (Git.Repo -> RawFilePath) -> Annex Bool
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue