diff options
author | 2016-02-14 17:09:54 -0400 | |
---|---|---|
committer | 2016-02-14 17:09:54 -0400 | |
commit | 1d1ecd4d89160b8bdbef0179ceb519f00bbe16eb (patch) | |
tree | 44631bc35ebd08a9efad00f1f31097a1053661d9 | |
parent | b2ae82e9cb2357b38e1c80f011d49bdd9d9f9e2d (diff) |
fsck: Detect and fix missing associated file mappings in v6 repositories.
This also handles fixing up after the bad data written by
f9dfeaf801da2e4d5879b3de5895dc3cef68a329.
-rw-r--r-- | Command/Fsck.hs | 28 | ||||
-rw-r--r-- | debian/changelog | 1 |
2 files changed, 23 insertions, 6 deletions
diff --git a/Command/Fsck.hs b/Command/Fsck.hs index afc0f6307..7341ab5e5 100644 --- a/Command/Fsck.hs +++ b/Command/Fsck.hs @@ -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 diff --git a/debian/changelog b/debian/changelog index d44af9ded..c7d9bd8a7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 |