From 664f736f34a914ea995862f73aad56ee87b3da6e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 22 Feb 2013 15:19:28 -0400 Subject: fix sameInodeCache to check the inode change sentinal This should fix the problem where the assistant, on Android, re-adds every file on startup. --- Annex/Content/Direct.hs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Annex/Content/Direct.hs b/Annex/Content/Direct.hs index deca13d65..3bb38764b 100644 --- a/Annex/Content/Direct.hs +++ b/Annex/Content/Direct.hs @@ -103,7 +103,10 @@ changedFileStatus :: Key -> FileStatus -> Annex Bool changedFileStatus key status = do old <- recordedInodeCache key let curr = toInodeCache status - return $ curr /= old + case (old, curr) of + (Just o, Just c) -> compareInodeCaches o c + (Nothing, Nothing) -> return True + _ -> return False {- Gets the recorded inode cache for a key. -} recordedInodeCache :: Key -> Annex (Maybe InodeCache) @@ -130,21 +133,22 @@ removeInodeCache key = withInodeCacheFile key $ \f -> do withInodeCacheFile :: Key -> (FilePath -> Annex a) -> Annex a withInodeCacheFile key a = a =<< inRepo (gitAnnexInodeCache key) -{- Checks if a file's InodeCache matches its current info. - - - - If the inodes have changed, only the size and mtime are compared. - -} +{- Checks if a InodeCache matches the current version of a file. -} sameInodeCache :: FilePath -> Maybe InodeCache -> Annex Bool sameInodeCache _ Nothing = return False sameInodeCache file (Just old) = go =<< liftIO (genInodeCache file) where go Nothing = return False - go (Just curr) - | curr == old = return True - | otherwise = ifM inodesChanged - ( return $ compareWeak curr old - , return False - ) + go (Just curr) = compareInodeCaches curr old + +{- If the inodes have changed, only the size and mtime are compared. -} +compareInodeCaches :: InodeCache -> InodeCache -> Annex Bool +compareInodeCaches x y + | x == y = return True + | otherwise = ifM inodesChanged + ( return $ compareWeak x y + , return False + ) {- Some filesystems get new inodes each time they are mounted. - In order to work on such a filesystem, a sentinal file is used to detect -- cgit v1.2.3