fsck: Detect and fix missing associated file mappings in v6 repositories.
This also handles fixing up after the bad data written by
cf260d9a15
.
This commit is contained in:
parent
74bbdfa888
commit
675321264f
2 changed files with 23 additions and 6 deletions
|
@ -114,12 +114,12 @@ start from inc file key = do
|
|||
|
||||
perform :: Key -> FilePath -> Backend -> NumCopies -> Annex Bool
|
||||
perform key file backend numcopies = do
|
||||
keystatus <- getKeyStatus key
|
||||
keystatus <- getKeyFileStatus key file
|
||||
check
|
||||
-- order matters
|
||||
[ fixLink key file
|
||||
, verifyLocationLog key keystatus file
|
||||
, verifyAssociatedFiles key file
|
||||
, verifyAssociatedFiles key keystatus file
|
||||
, verifyDirectMode key file
|
||||
, checkKeySize key keystatus
|
||||
, checkBackend backend key keystatus (Just file)
|
||||
|
@ -262,8 +262,8 @@ verifyLocationLog' key desc present u updatestatus = do
|
|||
updatestatus s
|
||||
|
||||
{- Verifies the associated file records. -}
|
||||
verifyAssociatedFiles :: Key -> FilePath -> Annex Bool
|
||||
verifyAssociatedFiles key file = do
|
||||
verifyAssociatedFiles :: Key -> KeyStatus -> FilePath -> Annex Bool
|
||||
verifyAssociatedFiles key keystatus file = do
|
||||
ifM isDirect (godirect, goindirect)
|
||||
return True
|
||||
where
|
||||
|
@ -272,7 +272,13 @@ verifyAssociatedFiles key file = do
|
|||
forM_ fs $ \f ->
|
||||
unlessM (liftIO $ doesFileExist f) $
|
||||
void $ Direct.removeAssociatedFile key f
|
||||
goindirect = return ()
|
||||
goindirect = case keystatus of
|
||||
KeyUnlocked -> do
|
||||
f <- inRepo $ toTopFilePath file
|
||||
afs <- Database.Keys.getAssociatedFiles key
|
||||
unless (getTopFilePath f `elem` map getTopFilePath afs) $
|
||||
Database.Keys.addAssociatedFile key f
|
||||
_ -> return ()
|
||||
|
||||
{- Ensures that files whose content is available are in direct mode. -}
|
||||
verifyDirectMode :: Key -> FilePath -> Annex Bool
|
||||
|
@ -587,7 +593,17 @@ getKeyStatus :: Key -> Annex KeyStatus
|
|||
getKeyStatus key = ifM isDirect
|
||||
( return KeyUnlocked
|
||||
, catchDefaultIO KeyMissing $ do
|
||||
obj <- calcRepo $ gitAnnexLocation key
|
||||
unlocked <- not . null <$> Database.Keys.getAssociatedFiles key
|
||||
return $ if unlocked then KeyUnlocked else KeyLocked
|
||||
)
|
||||
|
||||
getKeyFileStatus :: Key -> FilePath -> Annex KeyStatus
|
||||
getKeyFileStatus key file = do
|
||||
s <- getKeyStatus key
|
||||
case s of
|
||||
KeyLocked -> catchDefaultIO KeyLocked $
|
||||
ifM (isJust <$> isAnnexLink file)
|
||||
( return KeyLocked
|
||||
, return KeyUnlocked
|
||||
)
|
||||
_ -> return s
|
||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -8,6 +8,7 @@ git-annex (6.20160212) UNRELEASED; urgency=medium
|
|||
it was built without concurrent-output support in this situation.
|
||||
* Fix storing of filenames of v6 unlocked files when the filename is not
|
||||
representable in the current locale.
|
||||
* fsck: Detect and fix missing associated file mappings in v6 repositories.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Fri, 12 Feb 2016 14:03:46 -0400
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue