From f80592f1603fdfdde4b092e9880646ded505163a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 9 Jun 2015 14:08:57 -0400 Subject: fsck: Ignore keys that are known to be dead when running in --all mode or a in a bare repo. Otherwise, still reports files with lost contents, even if the content is dead. --- Command/Fsck.hs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'Command/Fsck.hs') diff --git a/Command/Fsck.hs b/Command/Fsck.hs index 26c788d56..6dccb285b 100644 --- a/Command/Fsck.hs +++ b/Command/Fsck.hs @@ -99,7 +99,7 @@ perform key file backend numcopies = check , verifyDirectMode key file , checkKeySize key , checkBackend backend key (Just file) - , checkKeyNumCopies key file numcopies + , checkKeyNumCopies key (Just file) numcopies ] {- To fsck a remote, the content is retrieved to a tmp file, @@ -125,7 +125,7 @@ performRemote key file backend numcopies remote = [ verifyLocationLogRemote key file remote present , checkKeySizeRemote key remote localcopy , checkBackendRemote backend key remote localcopy - , checkKeyNumCopies key file numcopies + , checkKeyNumCopies key (Just file) numcopies ] withtmp a = do pid <- liftIO getPID @@ -160,7 +160,7 @@ performKey key backend numcopies = check [ verifyLocationLog key (key2file key) , checkKeySize key , checkBackend backend key Nothing - , checkKeyNumCopies key (key2file key) numcopies + , checkKeyNumCopies key Nothing numcopies ] check :: [Annex Bool] -> Annex Bool @@ -343,15 +343,21 @@ checkBackendOr' bad backend key file postcheck = , return True ) -checkKeyNumCopies :: Key -> String -> NumCopies -> Annex Bool -checkKeyNumCopies key file numcopies = do +checkKeyNumCopies :: Key -> AssociatedFile -> NumCopies -> Annex Bool +checkKeyNumCopies key afile numcopies = do + let file = fromMaybe (key2file key) afile (untrustedlocations, safelocations) <- trustPartition UnTrusted =<< Remote.keyLocations key let present = NumCopies (length safelocations) if present < numcopies - then do - ppuuids <- Remote.prettyPrintUUIDs "untrusted" untrustedlocations - warning $ missingNote file present numcopies ppuuids - return False + then ifM (pure (isNothing afile) <&&> checkDead key) + ( do + showLongNote $ "This key is dead, skipping." + return True + , do + ppuuids <- Remote.prettyPrintUUIDs "untrusted" untrustedlocations + warning $ missingNote file present numcopies ppuuids + return False + ) else return True missingNote :: String -> NumCopies -> NumCopies -> String -> String -- cgit v1.2.3