diff options
author | 2017-03-10 12:09:52 -0400 | |
---|---|---|
committer | 2017-03-10 12:11:00 -0400 | |
commit | f8b7f6a35b7a12822926eb8497d9f700bc258d5a (patch) | |
tree | 5906397520c33e305e2d8538d872f27ed98babad | |
parent | 797cc9bec701ded790768699d67bd215f418d90d (diff) |
fix fsck bug introduced in 1a497cefb47557f0b4788c606f9071be422b2511
Got two Maybe FilePaths crossed. Test suite caught it.
Slightly improved types to avoid this mistake.
-rw-r--r-- | Command/Fsck.hs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/Command/Fsck.hs b/Command/Fsck.hs index 2b4ec58b6..231f93ce7 100644 --- a/Command/Fsck.hs +++ b/Command/Fsck.hs @@ -149,8 +149,8 @@ performRemote key afile backend numcopies remote = dispatch (Right False) = go False Nothing go present localcopy = check [ verifyLocationLogRemote key (maybe (key2file key) id afile) remote present - , checkKeySizeRemote key remote localcopy afile - , checkBackendRemote backend key remote localcopy afile + , withLocalCopy localcopy $ checkKeySizeRemote key remote afile + , withLocalCopy localcopy $ checkBackendRemote backend key remote afile , checkKeyNumCopies key afile numcopies ] withtmp a = do @@ -347,10 +347,13 @@ checkKeySize key _ afile = do , return True ) -checkKeySizeRemote :: Key -> Remote -> Maybe FilePath -> AssociatedFile -> Annex Bool -checkKeySizeRemote _ _ Nothing _ = return True -checkKeySizeRemote key remote (Just file) afile = - checkKeySizeOr (badContentRemote remote file) key file afile +withLocalCopy :: Maybe FilePath -> (FilePath -> Annex Bool) -> Annex Bool +withLocalCopy Nothing _ = return True +withLocalCopy (Just localcopy) f = f localcopy + +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 bad key file afile = case keySize key of @@ -401,10 +404,9 @@ checkBackend backend key keystatus afile = go =<< isDirect ) nocheck = return True -checkBackendRemote :: Backend -> Key -> Remote -> Maybe FilePath -> AssociatedFile -> Annex Bool -checkBackendRemote backend key remote afile = maybe (return True) go - where - go file = checkBackendOr (badContentRemote remote file) backend key file afile +checkBackendRemote :: Backend -> Key -> Remote -> AssociatedFile -> FilePath -> Annex Bool +checkBackendRemote backend key remote afile localcopy = + checkBackendOr (badContentRemote remote localcopy) backend key localcopy afile checkBackendOr :: (Key -> Annex String) -> Backend -> Key -> FilePath -> AssociatedFile -> Annex Bool checkBackendOr bad backend key file afile = |