From 11e3b2397c7212253916487f40f0f8b83225fee2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 27 Aug 2019 13:54:21 -0400 Subject: [PATCH] update location log for missing content during direct mode conversion If a direct mode file is deleted or modified, and there are no other files containing the content, the content was lost. That's a normal thing that can happen in direct mode, but not in v7, so the upgrade code has to notice it in order for the location log to be accurate. --- Upgrade/V5.hs | 28 +++++++++++++------ ...direct_mode_upgrade_with_deleted_file.mdwn | 2 ++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Upgrade/V5.hs b/Upgrade/V5.hs index 98ec5df091..3ed6288ed6 100644 --- a/Upgrade/V5.hs +++ b/Upgrade/V5.hs @@ -15,6 +15,8 @@ import Annex.InodeSentinal import Annex.Link import Annex.CatFile import Annex.WorkTree +import Annex.UUID +import Logs.Location import qualified Annex.Content as Content import qualified Database.Keys import qualified Annex.Direct as Direct @@ -102,14 +104,24 @@ upgradeDirectWorkTree = do =<< inRepo (toTopFilePath f) go _ = noop - fromdirect f k = whenM (Direct.goodContent k f) $ do - -- If linkToAnnex fails for some reason, the work tree file - -- still has the content; the annex object file is just - -- not populated with it. Since the work tree file - -- is recorded as an associated file, things will still - -- work that way, it's just not ideal. - ic <- withTSDelta (liftIO . genInodeCache f) - void $ Content.linkToAnnex k f ic + fromdirect f k = ifM (Direct.goodContent k f) + ( do + -- If linkToAnnex fails for some reason, the work tree + -- file still has the content; the annex object file + -- is just not populated with it. Since the work tree + -- file is recorded as an associated file, things will + -- still work that way, it's just not ideal. + ic <- withTSDelta (liftIO . genInodeCache f) + void $ Content.linkToAnnex k f ic + , unlessM (Content.inAnnex k) $ do + -- Worktree file was deleted or modified; + -- if there are no other copies of the content + -- then it's been lost. + locs <- Direct.associatedFiles k + unlessM (anyM (Direct.goodContent k) locs) $ do + u <- getUUID + logChange k u InfoMissing + ) writepointer f k = liftIO $ do nukeFile f diff --git a/doc/bugs/direct_mode_upgrade_with_deleted_file.mdwn b/doc/bugs/direct_mode_upgrade_with_deleted_file.mdwn index c62f2a396b..dd9eb69720 100644 --- a/doc/bugs/direct_mode_upgrade_with_deleted_file.mdwn +++ b/doc/bugs/direct_mode_upgrade_with_deleted_file.mdwn @@ -8,6 +8,8 @@ But `git whereis` thinks the content is present, which it's not any longer. Seems that the upgrade process needs to notice when a deleted file was the only copy of the content, and set its content as not present. +> [[done]] --[[Joey]] + And `git fsck` doesn't find a problem, despite the content not being present. And does not fix the location log. This part may not be specific to this case, seems it must be some bug in