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.

This commit is contained in:
Joey Hess 2015-06-09 14:08:57 -04:00
parent 8976e4755c
commit 6eefc5db65
3 changed files with 32 additions and 14 deletions

View file

@ -99,7 +99,7 @@ perform key file backend numcopies = check
, verifyDirectMode key file , verifyDirectMode key file
, checkKeySize key , checkKeySize key
, checkBackend backend key (Just file) , 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, {- 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 [ verifyLocationLogRemote key file remote present
, checkKeySizeRemote key remote localcopy , checkKeySizeRemote key remote localcopy
, checkBackendRemote backend key remote localcopy , checkBackendRemote backend key remote localcopy
, checkKeyNumCopies key file numcopies , checkKeyNumCopies key (Just file) numcopies
] ]
withtmp a = do withtmp a = do
pid <- liftIO getPID pid <- liftIO getPID
@ -160,7 +160,7 @@ performKey key backend numcopies = check
[ verifyLocationLog key (key2file key) [ verifyLocationLog key (key2file key)
, checkKeySize key , checkKeySize key
, checkBackend backend key Nothing , checkBackend backend key Nothing
, checkKeyNumCopies key (key2file key) numcopies , checkKeyNumCopies key Nothing numcopies
] ]
check :: [Annex Bool] -> Annex Bool check :: [Annex Bool] -> Annex Bool
@ -343,15 +343,21 @@ checkBackendOr' bad backend key file postcheck =
, return True , return True
) )
checkKeyNumCopies :: Key -> String -> NumCopies -> Annex Bool checkKeyNumCopies :: Key -> AssociatedFile -> NumCopies -> Annex Bool
checkKeyNumCopies key file numcopies = do checkKeyNumCopies key afile numcopies = do
let file = fromMaybe (key2file key) afile
(untrustedlocations, safelocations) <- trustPartition UnTrusted =<< Remote.keyLocations key (untrustedlocations, safelocations) <- trustPartition UnTrusted =<< Remote.keyLocations key
let present = NumCopies (length safelocations) let present = NumCopies (length safelocations)
if present < numcopies if present < numcopies
then do then ifM (pure (isNothing afile) <&&> checkDead key)
ppuuids <- Remote.prettyPrintUUIDs "untrusted" untrustedlocations ( do
warning $ missingNote file present numcopies ppuuids showLongNote $ "This key is dead, skipping."
return False return True
, do
ppuuids <- Remote.prettyPrintUUIDs "untrusted" untrustedlocations
warning $ missingNote file present numcopies ppuuids
return False
)
else return True else return True
missingNote :: String -> NumCopies -> NumCopies -> String -> String missingNote :: String -> NumCopies -> NumCopies -> String -> String

View file

@ -8,7 +8,7 @@
- Repositories record their UUID and the date when they --get or --drop - Repositories record their UUID and the date when they --get or --drop
- a value. - a value.
- -
- Copyright 2010-2014 Joey Hess <id@joeyh.name> - Copyright 2010-2015 Joey Hess <id@joeyh.name>
- -
- Licensed under the GNU GPL version 3 or higher. - Licensed under the GNU GPL version 3 or higher.
-} -}
@ -19,7 +19,8 @@ module Logs.Location (
logChange, logChange,
loggedLocations, loggedLocations,
loggedLocationsHistorical, loggedLocationsHistorical,
locationLog, checkDead,
setDead,
loggedKeys, loggedKeys,
loggedKeysFor, loggedKeysFor,
) where ) where
@ -62,10 +63,18 @@ getLoggedLocations getter key = do
config <- Annex.getGitConfig config <- Annex.getGitConfig
map toUUID <$> getter (locationLogFile config key) map toUUID <$> getter (locationLogFile config key)
locationLog :: Key -> Annex [LogLine] {- For a key to be dead, all locations that have location status for the key
locationLog key = do - must have InfoDead set. -}
checkDead :: Key -> Annex Bool
checkDead key = do
config <- Annex.getGitConfig config <- Annex.getGitConfig
currentLog (locationLogFile config key) ls <- compactLog <$> readLog (locationLogFile config key)
return $ all (\l -> status l == InfoDead) ls
{- Updates the log to say that a key is dead. This changes all logged lines
- for the key, in any location, to be InfoDead. -}
setDead :: Key -> Annex ()
setDead key = undefined
{- Finds all keys that have location log information. {- Finds all keys that have location log information.
- (There may be duplicate keys in the list.) -} - (There may be duplicate keys in the list.) -}

3
debian/changelog vendored
View file

@ -16,6 +16,9 @@ git-annex (5.20150529) UNRELEASED; urgency=medium
the public to access the bucket's content. the public to access the bucket's content.
* S3: Publically accessible buckets can be used without creds. * S3: Publically accessible buckets can be used without creds.
* Re-remove dependency on obsolete hamlet package. Closes: #786659 * Re-remove dependency on obsolete hamlet package. Closes: #786659
* 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.
-- Joey Hess <id@joeyh.name> Sat, 30 May 2015 02:07:18 -0400 -- Joey Hess <id@joeyh.name> Sat, 30 May 2015 02:07:18 -0400