fix fsck bug introduced in 301aff34c4

Got two Maybe FilePaths crossed. Test suite caught it.
Slightly improved types to avoid this mistake.
This commit is contained in:
Joey Hess 2017-03-10 12:09:52 -04:00
parent 1f16b41ec2
commit f90e2d0893
No known key found for this signature in database
GPG key ID: C910D9222512E3C7

View file

@ -149,8 +149,8 @@ performRemote key afile backend numcopies remote =
dispatch (Right False) = go False Nothing dispatch (Right False) = go False Nothing
go present localcopy = check go present localcopy = check
[ verifyLocationLogRemote key (maybe (key2file key) id afile) remote present [ verifyLocationLogRemote key (maybe (key2file key) id afile) remote present
, checkKeySizeRemote key remote localcopy afile , withLocalCopy localcopy $ checkKeySizeRemote key remote afile
, checkBackendRemote backend key remote localcopy afile , withLocalCopy localcopy $ checkBackendRemote backend key remote afile
, checkKeyNumCopies key afile numcopies , checkKeyNumCopies key afile numcopies
] ]
withtmp a = do withtmp a = do
@ -347,10 +347,13 @@ checkKeySize key _ afile = do
, return True , return True
) )
checkKeySizeRemote :: Key -> Remote -> Maybe FilePath -> AssociatedFile -> Annex Bool withLocalCopy :: Maybe FilePath -> (FilePath -> Annex Bool) -> Annex Bool
checkKeySizeRemote _ _ Nothing _ = return True withLocalCopy Nothing _ = return True
checkKeySizeRemote key remote (Just file) afile = withLocalCopy (Just localcopy) f = f localcopy
checkKeySizeOr (badContentRemote remote file) key file afile
checkKeySizeRemote :: Key -> Remote -> AssociatedFile -> FilePath -> Annex Bool
checkKeySizeRemote key remote afile localcopy =
checkKeySizeOr (badContentRemote remote localcopy) key localcopy afile
checkKeySizeOr :: (Key -> Annex String) -> Key -> FilePath -> AssociatedFile -> Annex Bool checkKeySizeOr :: (Key -> Annex String) -> Key -> FilePath -> AssociatedFile -> Annex Bool
checkKeySizeOr bad key file afile = case keySize key of checkKeySizeOr bad key file afile = case keySize key of
@ -401,10 +404,9 @@ checkBackend backend key keystatus afile = go =<< isDirect
) )
nocheck = return True nocheck = return True
checkBackendRemote :: Backend -> Key -> Remote -> Maybe FilePath -> AssociatedFile -> Annex Bool checkBackendRemote :: Backend -> Key -> Remote -> AssociatedFile -> FilePath -> Annex Bool
checkBackendRemote backend key remote afile = maybe (return True) go checkBackendRemote backend key remote afile localcopy =
where checkBackendOr (badContentRemote remote localcopy) backend key localcopy afile
go file = checkBackendOr (badContentRemote remote file) backend key file afile
checkBackendOr :: (Key -> Annex String) -> Backend -> Key -> FilePath -> AssociatedFile -> Annex Bool checkBackendOr :: (Key -> Annex String) -> Backend -> Key -> FilePath -> AssociatedFile -> Annex Bool
checkBackendOr bad backend key file afile = checkBackendOr bad backend key file afile =