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
|
||||
|
|
|
@ -92,6 +92,7 @@ git-annex (10.20230408) UNRELEASED; urgency=medium
|
|||
* assistant: Fix a crash when a small file is deleted immediately after
|
||||
being created.
|
||||
* repair: Fix handling of git ref names on Windows.
|
||||
* repair: Fix a crash when .git/annex/journal/ does not exist.
|
||||
* Support building with optparse-applicative 0.18.1
|
||||
(Thanks, Peter Simons)
|
||||
|
||||
|
|
|
@ -48,3 +48,5 @@ I did that because annexed objects are 1.7TB big here, so I wanted a local copy
|
|||
I'll keep the repo lying around for a few days, maybe weeks, if some experiment or further feedback is needed.
|
||||
|
||||
Thank you for your attention.
|
||||
|
||||
> [[fixed|done]].. sorry for the delay and thanks for reporting --[[Joey]]
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
[[!comment format=mdwn
|
||||
username="joey"
|
||||
subject="""comment 1"""
|
||||
date="2023-06-21T18:53:31Z"
|
||||
content="""
|
||||
I was able to reproduce this bug!
|
||||
|
||||
git-annex init
|
||||
rm -rf .git/annex
|
||||
git-annex repair
|
||||
|
||||
git-annex: .git/annex/journal/: openDirStream: does not exist (No such file or directory)
|
||||
|
||||
That's with Annex.Repair modified to always run commitindex. Having a
|
||||
repository with a git-annex branch that is corrupt, would have the same effect
|
||||
as that modification.
|
||||
|
||||
Fixed this.
|
||||
"""]]
|
Loading…
Add table
Reference in a new issue