fsck: When the only copy of a file is in a dead repository, mention the repository.

This commit is contained in:
Joey Hess 2016-02-19 15:12:11 -04:00
parent e092ff087c
commit ec198fec83
Failed to extract signature
2 changed files with 21 additions and 11 deletions

View file

@ -409,7 +409,9 @@ checkBackendOr' bad backend key file postcheck =
checkKeyNumCopies :: Key -> AssociatedFile -> NumCopies -> Annex Bool checkKeyNumCopies :: Key -> AssociatedFile -> NumCopies -> Annex Bool
checkKeyNumCopies key afile numcopies = do checkKeyNumCopies key afile numcopies = do
let file = fromMaybe (key2file key) afile 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) let present = NumCopies (length safelocations)
if present < numcopies if present < numcopies
then ifM (pure (isNothing afile) <&&> checkDead key) then ifM (pure (isNothing afile) <&&> checkDead key)
@ -417,29 +419,35 @@ checkKeyNumCopies key afile numcopies = do
showLongNote $ "This key is dead, skipping." showLongNote $ "This key is dead, skipping."
return True return True
, do , do
ppuuids <- Remote.prettyPrintUUIDs "untrusted" untrustedlocations untrusted <- Remote.prettyPrintUUIDs "untrusted" untrustedlocations
warning $ missingNote file present numcopies ppuuids dead <- Remote.prettyPrintUUIDs "dead" deadlocations
warning $ missingNote file present numcopies untrusted dead
when (fromNumCopies present == 0 && isNothing afile) $ when (fromNumCopies present == 0 && isNothing afile) $
showLongNote "(Avoid this check by running: git annex dead --key )" showLongNote "(Avoid this check by running: git annex dead --key )"
return False return False
) )
else return True else return True
missingNote :: String -> NumCopies -> NumCopies -> String -> String missingNote :: String -> NumCopies -> NumCopies -> String -> String -> String
missingNote file (NumCopies 0) _ [] = missingNote file (NumCopies 0) _ [] dead =
"** No known copies exist of " ++ file "** No known copies exist of " ++ file ++ honorDead dead
missingNote file (NumCopies 0) _ untrusted = missingNote file (NumCopies 0) _ untrusted dead =
"Only these untrusted locations may have copies of " ++ file ++ "Only these untrusted locations may have copies of " ++ file ++
"\n" ++ untrusted ++ "\n" ++ untrusted ++
"Back it up to trusted locations with git-annex copy." "Back it up to trusted locations with git-annex copy." ++ honorDead dead
missingNote file present needed [] = missingNote file present needed [] _ =
"Only " ++ show (fromNumCopies present) ++ " of " ++ show (fromNumCopies needed) ++ "Only " ++ show (fromNumCopies present) ++ " of " ++ show (fromNumCopies needed) ++
" trustworthy copies exist of " ++ file ++ " trustworthy copies exist of " ++ file ++
"\nBack it up with git-annex copy." "\nBack it up with git-annex copy."
missingNote file present needed untrusted = missingNote file present needed untrusted dead =
missingNote file present needed [] ++ missingNote file present needed [] dead ++
"\nThe following untrusted locations may also have copies: " ++ "\nThe following untrusted locations may also have copies: " ++
"\n" ++ untrusted "\n" ++ untrusted
honorDead :: String -> String
honorDead dead
| null dead = ""
| otherwise = "\nThese dead repositories used to have copies\n" ++ dead
{- Bad content is moved aside. -} {- Bad content is moved aside. -}
badContent :: Key -> Annex String badContent :: Key -> Annex String

2
debian/changelog vendored
View file

@ -4,6 +4,8 @@ git-annex (6.20160218) UNRELEASED; urgency=medium
* Fix memory leak in last release, which affected commands like * Fix memory leak in last release, which affected commands like
git-annex status when a large non-annexed file is present in the work git-annex status when a large non-annexed file is present in the work
tree. tree.
* fsck: When the only copy of a file is in a dead repository, mention
the repository.
-- Joey Hess <id@joeyh.name> Thu, 18 Feb 2016 13:09:21 -0400 -- Joey Hess <id@joeyh.name> Thu, 18 Feb 2016 13:09:21 -0400