fastDebug "Annex.Content" ("found no inode cache for " ++ show f)
maybeToList <$>
withTSDelta (liftIO . genInodeCache f)
- else do
- fastDebug "Annex.Content" ("found inode cache for " ++ show f)
- pure cache
+ -- Verify that the object is not modified. Usually this
+ -- only has to check the inode cache, but if the cache
+ -- is somehow stale, it will fall back to verifying its
+ -- content.
+ else withTSDelta (liftIO . genInodeCache f) >>= \case
+ Just fc -> ifM (isUnmodified' key f fc cache)
+ ( do
+ fastDebug "Annex.Content" ("found inode cache for " ++ show f)
+ return (fc:cache)
+ , return []
+ )
+ Nothing -> return []
return $ if null cache'
then Nothing
else Just (fromRawFilePath f, sameInodeCache f cache')
{- git-annex object content presence
-
- - Copyright 2010-2020 Joey Hess <id@joeyh.name>
+ - Copyright 2010-2021 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
objectFileExists,
withObjectLoc,
isUnmodified,
+ isUnmodified',
isUnmodifiedCheap,
verifyKeyContent,
VerifyConfig(..),
- The cheaper way is to see if the InodeCache for the key matches the
- file. -}
isUnmodified :: Key -> RawFilePath -> Annex Bool
-isUnmodified key f = go =<< geti
+isUnmodified key f =
+ withTSDelta (liftIO . genInodeCache f) >>= \case
+ Just fc -> do
+ ic <- Database.Keys.getInodeCaches key
+ isUnmodified' key f fc ic
+ Nothing -> return False
+
+isUnmodified' :: Key -> RawFilePath -> InodeCache -> [InodeCache] -> Annex Bool
+isUnmodified' key f fc ic = isUnmodifiedCheap'' fc ic <||> expensivecheck
where
- go Nothing = return False
- go (Just fc) = isUnmodifiedCheap' key fc <||> expensivecheck fc
- expensivecheck fc = ifM (verifyKeyContent RetrievalAllKeysSecure AlwaysVerify UnVerified key f)
+ expensivecheck = ifM (verifyKeyContent RetrievalAllKeysSecure AlwaysVerify UnVerified key f)
( do
-- The file could have been modified while it was
-- being verified. Detect that.
=<< withTSDelta (liftIO . genInodeCache f)
isUnmodifiedCheap' :: Key -> InodeCache -> Annex Bool
-isUnmodifiedCheap' key fc =
- anyM (compareInodeCaches fc) =<< Database.Keys.getInodeCaches key
+isUnmodifiedCheap' key fc = isUnmodifiedCheap'' fc
+ =<< Database.Keys.getInodeCaches key
+
+isUnmodifiedCheap'' :: InodeCache -> [InodeCache] -> Annex Bool
+isUnmodifiedCheap'' fc ic = anyM (compareInodeCaches fc) ic
{- Verifies that a file is the expected content of a key.
-
histories.)
* sync, merge: Added --allow-unrelated-histories option, which
is the same as the git merge option.
+ * Fix bug that caused some transfers to incorrectly fail with
+ "content changed while it was being sent", when the content was not
+ changed.
-- Joey Hess <id@joeyh.name> Wed, 14 Jul 2021 14:26:36 -0400
--- /dev/null
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 19"""
+ date="2021-07-26T21:20:15Z"
+ content="""
+I've made it fall back to checking the file's content when the inode cache
+is somehow stale. I expect this will solve the problem. But, I would still
+like to know how to reproduce the problem, because if something is making
+the inode cache go stale, this fallback check will need to hash the file,
+which could make git-annex significantly more expensive.
+"""]]