summaryrefslogtreecommitdiff
path: root/Command/Fsck.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-11-16 15:32:49 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-11-16 15:33:57 -0400
commitedacb971d687c44f2d076e0eff2ba8bb0a1b9019 (patch)
tree003856cf01aea273fceae11d8ecf5f44ef2f2e5b /Command/Fsck.hs
parent84db9788226be2c558906fb5debc994b855dd063 (diff)
fsck --all --from was checking the content of files in the local repository, rather than on the special remote.
Straight up forgot to handle this case! This commit was sponsored by Fernando Jimenez on Patreon.
Diffstat (limited to 'Command/Fsck.hs')
-rw-r--r--Command/Fsck.hs22
1 files changed, 12 insertions, 10 deletions
diff --git a/Command/Fsck.hs b/Command/Fsck.hs
index 9383c07f2..96ffd35da 100644
--- a/Command/Fsck.hs
+++ b/Command/Fsck.hs
@@ -89,7 +89,7 @@ seek o = allowConcurrentOutput $ do
checkDeadRepo u
i <- prepIncremental u (incrementalOpt o)
withKeyOptions (keyOptions o) False
- (\k ai -> startKey i k ai =<< getNumCopies)
+ (\k ai -> startKey from i k ai =<< getNumCopies)
(withFilesInGit $ whenAnnexed $ start from i)
(fsckFiles o)
cleanupIncremental i
@@ -109,7 +109,7 @@ start from inc file key = do
numcopies <- getFileNumCopies file
case from of
Nothing -> go $ perform key file backend numcopies
- Just r -> go $ performRemote key file backend numcopies r
+ Just r -> go $ performRemote key (Just file) backend numcopies r
where
go = runFsck inc (mkActionItem (Just file)) key
@@ -129,8 +129,8 @@ perform key file backend numcopies = do
{- To fsck a remote, the content is retrieved to a tmp file,
- and checked locally. -}
-performRemote :: Key -> FilePath -> Backend -> NumCopies -> Remote -> Annex Bool
-performRemote key file backend numcopies remote =
+performRemote :: Key -> AssociatedFile -> Backend -> NumCopies -> Remote -> Annex Bool
+performRemote key afile backend numcopies remote =
dispatch =<< Remote.hasKey remote key
where
dispatch (Left err) = do
@@ -147,10 +147,10 @@ performRemote key file backend numcopies remote =
return False
dispatch (Right False) = go False Nothing
go present localcopy = check
- [ verifyLocationLogRemote key file remote present
+ [ verifyLocationLogRemote key (maybe (key2file key) id afile) remote present
, checkKeySizeRemote key remote localcopy
, checkBackendRemote backend key remote localcopy
- , checkKeyNumCopies key (Just file) numcopies
+ , checkKeyNumCopies key afile numcopies
]
withtmp a = do
pid <- liftIO getPID
@@ -161,7 +161,7 @@ performRemote key file backend numcopies remote =
cleanup
cleanup `after` a tmp
getfile tmp = ifM (checkDiskSpace (Just (takeDirectory tmp)) key 0 True)
- ( ifM (Remote.retrieveKeyFileCheap remote key (Just file) tmp)
+ ( ifM (Remote.retrieveKeyFileCheap remote key afile tmp)
( return (Just True)
, ifM (Annex.getState Annex.fast)
( return Nothing
@@ -173,12 +173,14 @@ performRemote key file backend numcopies remote =
)
dummymeter _ = noop
-startKey :: Incremental -> Key -> ActionItem -> NumCopies -> CommandStart
-startKey inc key ai numcopies =
+startKey :: Maybe Remote -> Incremental -> Key -> ActionItem -> NumCopies -> CommandStart
+startKey from inc key ai numcopies =
case Backend.maybeLookupBackendName (keyBackendName key) of
Nothing -> stop
Just backend -> runFsck inc ai key $
- performKey key backend numcopies
+ case from of
+ Nothing -> performKey key backend numcopies
+ Just r -> performRemote key Nothing backend numcopies r
performKey :: Key -> Backend -> NumCopies -> Annex Bool
performKey key backend numcopies = do