fix add of file that was locked but has been replaced by a new, unlocked file (v6)

This commit is contained in:
Joey Hess 2015-12-16 14:53:41 -04:00
parent 35f6a78b66
commit 2d343224dc
Failed to extract signature

View file

@ -34,6 +34,7 @@ import Utility.Tmp
import Utility.CopyFile import Utility.CopyFile
import Annex.InodeSentinal import Annex.InodeSentinal
import Annex.Version import Annex.Version
import qualified Database.Keys
import Control.Exception (IOException) import Control.Exception (IOException)
@ -105,13 +106,22 @@ start file = ifAnnexed file addpresent add
next $ if isSymbolicLink s next $ if isSymbolicLink s
then next $ addFile file then next $ addFile file
else perform file else perform file
addpresent key = ifM isDirect addpresent key = ifM versionSupportsUnlockedPointers
( do ( do
ms <- liftIO $ catchMaybeIO $ getSymbolicLinkStatus file ms <- liftIO $ catchMaybeIO $ getSymbolicLinkStatus file
case ms of case ms of
Just s | isSymbolicLink s -> fixup key Just s | isSymbolicLink s -> fixup key
_ -> ifM (goodContent key file) ( stop , add ) _ -> ifM (sameInodeCache file =<< Database.Keys.getInodeCaches key)
, fixup key ( stop, add )
, ifM isDirect
( do
ms <- liftIO $ catchMaybeIO $ getSymbolicLinkStatus file
case ms of
Just s | isSymbolicLink s -> fixup key
_ -> ifM (goodContent key file)
( stop , add )
, fixup key
)
) )
fixup key = do fixup key = do
-- the annexed symlink is present but not yet added to git -- the annexed symlink is present but not yet added to git