diff options
-rw-r--r-- | Annex/Content/Direct.hs | 6 | ||||
-rw-r--r-- | Annex/Direct.hs | 2 | ||||
-rw-r--r-- | Assistant/Threads/Watcher.hs | 2 | ||||
-rw-r--r-- | Command/Add.hs | 5 | ||||
-rw-r--r-- | Command/Status.hs | 2 | ||||
-rw-r--r-- | Utility/InodeCache.hs | 14 |
6 files changed, 15 insertions, 16 deletions
diff --git a/Annex/Content/Direct.hs b/Annex/Content/Direct.hs index c09a08f0d..4392b5198 100644 --- a/Annex/Content/Direct.hs +++ b/Annex/Content/Direct.hs @@ -174,10 +174,10 @@ sameInodeCache file old = go =<< withTSDelta (liftIO . genInodeCache file) go (Just curr) = elemInodeCaches curr old {- Checks if a FileStatus matches the recorded InodeCache of a file. -} -sameFileStatus :: Key -> FileStatus -> Annex Bool -sameFileStatus key status = do +sameFileStatus :: Key -> FilePath -> FileStatus -> Annex Bool +sameFileStatus key f status = do old <- recordedInodeCache key - curr <- withTSDelta $ \delta -> liftIO $ toInodeCache delta status + curr <- withTSDelta $ \delta -> liftIO $ toInodeCache delta f status case (old, curr) of (_, Just c) -> elemInodeCaches c old ([], Nothing) -> return True diff --git a/Annex/Direct.hs b/Annex/Direct.hs index df1c8f239..998849ad3 100644 --- a/Annex/Direct.hs +++ b/Annex/Direct.hs @@ -56,7 +56,7 @@ stageDirect = do go (file, Just sha, Just mode) = withTSDelta $ \delta -> do shakey <- catKey sha mode mstat <- liftIO $ catchMaybeIO $ getSymbolicLinkStatus file - mcache <- liftIO $ maybe (pure Nothing) (toInodeCache delta) mstat + mcache <- liftIO $ maybe (pure Nothing) (toInodeCache delta file) mstat filekey <- isAnnexLink file case (shakey, filekey, mstat, mcache) of (_, Just key, _, _) diff --git a/Assistant/Threads/Watcher.hs b/Assistant/Threads/Watcher.hs index 2e69e1640..a921861b8 100644 --- a/Assistant/Threads/Watcher.hs +++ b/Assistant/Threads/Watcher.hs @@ -224,7 +224,7 @@ onAddDirect symlinkssupported matcher file fs = do v <- liftAnnex $ catKeyFile file case (v, fs) of (Just key, Just filestatus) -> - ifM (liftAnnex $ sameFileStatus key filestatus) + ifM (liftAnnex $ sameFileStatus key file filestatus) {- It's possible to get an add event for - an existing file that is not - really modified, but it might have diff --git a/Command/Add.hs b/Command/Add.hs index 519dad6e4..d745000f8 100644 --- a/Command/Add.hs +++ b/Command/Add.hs @@ -160,8 +160,9 @@ ingest Nothing = return (Nothing, Nothing) ingest (Just source) = withTSDelta $ \delta -> do backend <- chooseBackend $ keyFilename source k <- genKey source backend - ms <- liftIO $ catchMaybeIO $ getFileStatus $ contentLocation source - mcache <- maybe (pure Nothing) (liftIO . toInodeCache delta) ms + let src = contentLocation source + ms <- liftIO $ catchMaybeIO $ getFileStatus src + mcache <- maybe (pure Nothing) (liftIO . toInodeCache delta src) ms case (mcache, inodeCache source) of (_, Nothing) -> go k mcache ms (Just newc, Just c) | compareStrong c newc -> go k mcache ms diff --git a/Command/Status.hs b/Command/Status.hs index 578538ca7..f49684258 100644 --- a/Command/Status.hs +++ b/Command/Status.hs @@ -70,7 +70,7 @@ statusDirect f = checkstatus =<< liftIO (catchMaybeIO $ getFileStatus f) | not (isSymbolicLink s) = checkkey s =<< catKeyFile f | otherwise = Just <$> checkNew f - checkkey s (Just k) = ifM (sameFileStatus k s) + checkkey s (Just k) = ifM (sameFileStatus k f s) ( return Nothing , return $ Just ModifiedFile ) diff --git a/Utility/InodeCache.hs b/Utility/InodeCache.hs index 0b0b040cb..d068e3801 100644 --- a/Utility/InodeCache.hs +++ b/Utility/InodeCache.hs @@ -40,15 +40,12 @@ module Utility.InodeCache ( import Common import System.PosixCompat.Types import Utility.QuickCheck --- While fileSize overflows and wraps at 2gb on Windows, --- it's ok for purposes of comparison. -import System.PosixCompat.Files (fileSize) #ifdef mingw32_HOST_OS import Data.Word (Word64) #endif -data InodeCachePrim = InodeCachePrim FileID FileOffset EpochTime +data InodeCachePrim = InodeCachePrim FileID Integer EpochTime deriving (Show, Eq, Ord) newtype InodeCache = InodeCache InodeCachePrim @@ -115,15 +112,16 @@ readInodeCache s = case words s of genInodeCache :: FilePath -> TSDelta -> IO (Maybe InodeCache) genInodeCache f delta = catchDefaultIO Nothing $ - toInodeCache delta =<< getFileStatus f + toInodeCache delta f =<< getFileStatus f -toInodeCache :: TSDelta -> FileStatus -> IO (Maybe InodeCache) -toInodeCache (TSDelta getdelta) s +toInodeCache :: TSDelta -> FilePath -> FileStatus -> IO (Maybe InodeCache) +toInodeCache (TSDelta getdelta) f s | isRegularFile s = do delta <- getdelta + sz <- getFileSize' f s return $ Just $ InodeCache $ InodeCachePrim (fileID s) - (fileSize s) + sz (modificationTime s + delta) | otherwise = pure Nothing |