Add locking to avoid races when changing the git-annex branch.

This commit is contained in:
Joey Hess 2011-10-03 16:32:36 -04:00
parent f77979b8b5
commit d357556141
4 changed files with 29 additions and 12 deletions

View file

@ -18,6 +18,7 @@ module Locations (
gitAnnexBadLocation,
gitAnnexUnusedLog,
gitAnnexJournalDir,
gitAnnexJournalLock,
isLinkToAnnex,
hashDirMixed,
hashDirLower,
@ -109,6 +110,10 @@ gitAnnexUnusedLog prefix r = gitAnnexDir r </> (prefix ++ "unused")
gitAnnexJournalDir :: Git.Repo -> FilePath
gitAnnexJournalDir r = addTrailingPathSeparator $ gitAnnexDir r </> "journal"
{- Lock file for the journal. -}
gitAnnexJournalLock :: Git.Repo -> FilePath
gitAnnexJournalLock r = gitAnnexDir r </> "journal.lck"
{- Checks a symlink target to see if it appears to point to annexed content. -}
isLinkToAnnex :: FilePath -> Bool
isLinkToAnnex s = ("/.git/" ++ objectDir) `isInfixOf` s