summaryrefslogtreecommitdiff
path: root/Annex/InodeSentinal.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2015-12-10 14:20:38 -0400
committerJoey Hess <joeyh@joeyh.name>2015-12-10 14:20:38 -0400
commit3b2a7f216d3c6aa9d82b275f83fd1e07de0f8be4 (patch)
treedd6a46a14af824969a8dc0b9027766efcbd3e9c5 /Annex/InodeSentinal.hs
parent3d936fdb59b4af8565ab914eb2ea860e98b47e92 (diff)
move
Diffstat (limited to 'Annex/InodeSentinal.hs')
-rw-r--r--Annex/InodeSentinal.hs19
1 files changed, 18 insertions, 1 deletions
diff --git a/Annex/InodeSentinal.hs b/Annex/InodeSentinal.hs
index 450e3b9677..8b48094dfc 100644
--- a/Annex/InodeSentinal.hs
+++ b/Annex/InodeSentinal.hs
@@ -14,7 +14,8 @@ import qualified Annex
import Utility.InodeCache
import Annex.Perms
-{- If the inodes have changed, only the size and mtime are compared. -}
+{- If the sendinal shows the inodes have changed, only the size and mtime
+ - are compared. -}
compareInodeCaches :: InodeCache -> InodeCache -> Annex Bool
compareInodeCaches x y
| compareStrong x y = return True
@@ -23,6 +24,22 @@ compareInodeCaches x y
, return False
)
+{- Checks if one of the provided old InodeCache matches the current
+ - version of a file. -}
+sameInodeCache :: FilePath -> [InodeCache] -> Annex Bool
+sameInodeCache _ [] = return False
+sameInodeCache file old = go =<< withTSDelta (liftIO . genInodeCache file)
+ where
+ go Nothing = return False
+ go (Just curr) = elemInodeCaches curr old
+
+elemInodeCaches :: InodeCache -> [InodeCache] -> Annex Bool
+elemInodeCaches _ [] = return False
+elemInodeCaches c (l:ls) = ifM (compareInodeCaches c l)
+ ( return True
+ , elemInodeCaches c ls
+ )
+
{- 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
- when the inodes have changed.