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.
This commit is contained in:
parent
da6f4d8887
commit
11e3b2397c
2 changed files with 22 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue