aboutsummaryrefslogtreecommitdiff
path: root/Utility/InodeCache.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-06-11 14:46:03 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-06-11 14:46:03 -0400
commit37f848ace7eec5c73185e9c15b7063975bbcd4c8 (patch)
tree3156905921b44cb184391b9dee2b55b30821f1ad /Utility/InodeCache.hs
parent73c8710be16359d3cf6e165f862c9759447d6219 (diff)
deal with FAT on Linux timestamp issue
Deal with FAT's low resolution timestamps, which in combination with Linux's caching of higher res timestamps while a FAT is mounted, caused direct mode repositories on FAT to seem to have modified files after they were unmounted and remounted. This commit was sponsored by Fabrice Rossi.
Diffstat (limited to 'Utility/InodeCache.hs')
-rw-r--r--Utility/InodeCache.hs11
1 files changed, 9 insertions, 2 deletions
diff --git a/Utility/InodeCache.hs b/Utility/InodeCache.hs
index a24bce546..c142114cb 100644
--- a/Utility/InodeCache.hs
+++ b/Utility/InodeCache.hs
@@ -28,10 +28,17 @@ compareStrong (InodeCache x) (InodeCache y) = x == y
{- Weak comparison of the inode caches, comparing the size and mtime,
- but not the actual inode. Useful when inodes have changed, perhaps
- - due to some filesystems being remounted. -}
+ - due to some filesystems being remounted.
+ -
+ - The weak mtime comparison treats any mtimes that are within 2 seconds
+ - of one-anther as the same. This is because FAT has only a 2 second
+ - resolution. When a FAT filesystem is used on Linux, higher resolution
+ - timestamps are cached and used by Linux, but this is lost on unmount,
+ - so after a remount, the timestamp can appear to have changed.
+ -}
compareWeak :: InodeCache -> InodeCache -> Bool
compareWeak (InodeCache (InodeCachePrim _ size1 mtime1)) (InodeCache (InodeCachePrim _ size2 mtime2)) =
- size1 == size2 && mtime1 == mtime2
+ size1 == size2 && (abs (mtime1 - mtime2) < 2)
compareBy :: InodeComparisonType -> InodeCache -> InodeCache -> Bool
compareBy Strongly = compareStrong