From 00e240f3803384ae8761f2d5bc95319351f4e0fa Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 22 Dec 2015 15:20:03 -0400 Subject: make linkAnnex detect when the file changes as it's being copied/linked in This fixes a race where the modified file ended up in annex/objects, and the InodeCache stored in the database was for the modified version, so git-annex didn't know it had gotten modified. The race could occur when the smudge filter was running; now it gets the InodeCache before generating the Key, which avoids the race. --- Command/Unlock.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Command/Unlock.hs') diff --git a/Command/Unlock.hs b/Command/Unlock.hs index 1cfd4a0b2..b82f78096 100644 --- a/Command/Unlock.hs +++ b/Command/Unlock.hs @@ -14,6 +14,8 @@ import Annex.CatFile import Annex.Version import Annex.Link import Annex.ReplaceFile +import Annex.InodeSentinal +import Utility.InodeCache import Utility.CopyFile cmd :: Command @@ -51,8 +53,9 @@ start file key = ifM (isJust <$> isAnnexLink file) performNew :: FilePath -> Key -> CommandPerform performNew dest key = do src <- calcRepo (gitAnnexLocation key) + srcic <- withTSDelta (liftIO . genInodeCache src) replaceFile dest $ \tmp -> do - r <- linkAnnex' key src tmp + r <- linkAnnex' key src srcic tmp case r of LinkAnnexOk -> return () _ -> error "linkAnnex failed" -- cgit v1.2.3