aboutsummaryrefslogtreecommitdiff
path: root/Utility/InodeCache.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-03-11 02:57:48 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-03-11 02:57:48 -0400
commita41051e59143824921a7e6e3d60bc2b50881d4b4 (patch)
treefcf1f3cadedd053b2ee2206d600350a763526228 /Utility/InodeCache.hs
parent9b5b4d3df90eee8e6a9a25bda22f41e82adeaf18 (diff)
remove Eq instance for InodeCache
There are two types of equality here, and which one is right varies, so this forces me to consider and choose between them. Based on this, I learned that the commit in git anex sync was always doing a strong comparison, even when in a repository where the inodes had changed. Fixed that.
Diffstat (limited to 'Utility/InodeCache.hs')
-rw-r--r--Utility/InodeCache.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/Utility/InodeCache.hs b/Utility/InodeCache.hs
index 5b9bdebcb..1d3f17887 100644
--- a/Utility/InodeCache.hs
+++ b/Utility/InodeCache.hs
@@ -12,7 +12,11 @@ import System.Posix.Types
import Utility.QuickCheck
data InodeCache = InodeCache FileID FileOffset EpochTime
- deriving (Eq, Show)
+ deriving (Show)
+
+compareStrong :: InodeCache -> InodeCache -> Bool
+compareStrong (InodeCache inode1 size1 mtime1) (InodeCache inode2 size2 mtime2) =
+ inode1 == inode2 && size1 == size2 && mtime1 == mtime2
{- Weak comparison of the inode caches, comparing the size and mtime, but
- not the actual inode. Useful when inodes have changed, perhaps
@@ -54,4 +58,6 @@ instance Arbitrary InodeCache where
<*> arbitrary
prop_read_show_inodecache :: InodeCache -> Bool
-prop_read_show_inodecache c = readInodeCache (showInodeCache c) == Just c
+prop_read_show_inodecache c = case readInodeCache (showInodeCache c) of
+ Nothing -> False
+ Just c' -> compareStrong c c'