summaryrefslogtreecommitdiff
path: root/Command/Fsck.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-02-19 15:12:11 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-02-19 15:12:11 -0400
commit3a1e7bbc58363b8b9ef223a3fdc0f87db8b020f5 (patch)
tree1ea8f39f23945fdeb9754ae99d341c1cf97197d1 /Command/Fsck.hs
parent6d4b67cb213ed74661bee8315d0048e99d8ef386 (diff)
fsck: When the only copy of a file is in a dead repository, mention the repository.
Diffstat (limited to 'Command/Fsck.hs')
-rw-r--r--Command/Fsck.hs30
1 files changed, 19 insertions, 11 deletions
diff --git a/Command/Fsck.hs b/Command/Fsck.hs
index 3b31b7211..2e7579b5b 100644
--- a/Command/Fsck.hs
+++ b/Command/Fsck.hs
@@ -409,7 +409,9 @@ checkBackendOr' bad backend key file postcheck =
checkKeyNumCopies :: Key -> AssociatedFile -> NumCopies -> Annex Bool
checkKeyNumCopies key afile numcopies = do
let file = fromMaybe (key2file key) afile
- (untrustedlocations, safelocations) <- trustPartition UnTrusted =<< Remote.keyLocations key
+ locs <- loggedLocations key
+ (untrustedlocations, otherlocations) <- trustPartition UnTrusted locs
+ (deadlocations, safelocations) <- trustPartition DeadTrusted otherlocations
let present = NumCopies (length safelocations)
if present < numcopies
then ifM (pure (isNothing afile) <&&> checkDead key)
@@ -417,29 +419,35 @@ checkKeyNumCopies key afile numcopies = do
showLongNote $ "This key is dead, skipping."
return True
, do
- ppuuids <- Remote.prettyPrintUUIDs "untrusted" untrustedlocations
- warning $ missingNote file present numcopies ppuuids
+ untrusted <- Remote.prettyPrintUUIDs "untrusted" untrustedlocations
+ dead <- Remote.prettyPrintUUIDs "dead" deadlocations
+ warning $ missingNote file present numcopies untrusted dead
when (fromNumCopies present == 0 && isNothing afile) $
showLongNote "(Avoid this check by running: git annex dead --key )"
return False
)
else return True
-missingNote :: String -> NumCopies -> NumCopies -> String -> String
-missingNote file (NumCopies 0) _ [] =
- "** No known copies exist of " ++ file
-missingNote file (NumCopies 0) _ untrusted =
+missingNote :: String -> NumCopies -> NumCopies -> String -> String -> String
+missingNote file (NumCopies 0) _ [] dead =
+ "** No known copies exist of " ++ file ++ honorDead dead
+missingNote file (NumCopies 0) _ untrusted dead =
"Only these untrusted locations may have copies of " ++ file ++
"\n" ++ untrusted ++
- "Back it up to trusted locations with git-annex copy."
-missingNote file present needed [] =
+ "Back it up to trusted locations with git-annex copy." ++ honorDead dead
+missingNote file present needed [] _ =
"Only " ++ show (fromNumCopies present) ++ " of " ++ show (fromNumCopies needed) ++
" trustworthy copies exist of " ++ file ++
"\nBack it up with git-annex copy."
-missingNote file present needed untrusted =
- missingNote file present needed [] ++
+missingNote file present needed untrusted dead =
+ missingNote file present needed [] dead ++
"\nThe following untrusted locations may also have copies: " ++
"\n" ++ untrusted
+
+honorDead :: String -> String
+honorDead dead
+ | null dead = ""
+ | otherwise = "\nThese dead repositories used to have copies\n" ++ dead
{- Bad content is moved aside. -}
badContent :: Key -> Annex String