summaryrefslogtreecommitdiff
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
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.
-rw-r--r--CHANGELOG2
-rw-r--r--Command/Fsck.hs22
-rw-r--r--doc/bugs/git-annex-fsck___34__-all__34___flag_doesn__39__t_work_for_special_remote.mdwn2
3 files changed, 16 insertions, 10 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 71ef1c100..6dd4edb3e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,8 @@ git-annex (6.20161112) UNRELEASED; urgency=medium
direct mode repository work the same as it works in indirect mode.
* Avoid backtraces on expected failures when built with ghc 8;
only use backtraces for unexpected errors.
+ * fsck --all --from was checking the existence and content of files
+ in the local repository, rather than on the special remote. Oops.
-- Joey Hess <id@joeyh.name> Tue, 15 Nov 2016 11:15:27 -0400
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
diff --git a/doc/bugs/git-annex-fsck___34__-all__34___flag_doesn__39__t_work_for_special_remote.mdwn b/doc/bugs/git-annex-fsck___34__-all__34___flag_doesn__39__t_work_for_special_remote.mdwn
index b9895056f..80193cd54 100644
--- a/doc/bugs/git-annex-fsck___34__-all__34___flag_doesn__39__t_work_for_special_remote.mdwn
+++ b/doc/bugs/git-annex-fsck___34__-all__34___flag_doesn__39__t_work_for_special_remote.mdwn
@@ -24,3 +24,5 @@ I tried to use `git-annex-fsck --all --from remote` to check files on a special
### Have you had any luck using git-annex before?
Yes, it's been very helpful for managing large files between laptops, desktops, external storage, and remote storage.
+> Thanks for an excellent test case and a clear bug report. I've fixed this
+> bug. [[done]] --[[Joey]]