diff options
author | Joey Hess <joey@kitenet.net> | 2013-02-05 16:48:00 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-02-05 16:48:00 -0400 |
commit | 4b690643b335b8892a0fb3b8cb05b7b50f987a36 (patch) | |
tree | 79a566f701cada6d870c388a5f8447aa9b255ee5 /Annex | |
parent | 053587b22832cc0db37055ee90ebd9bb066b29d9 (diff) |
Deal with stale mappings for deleted file in direct mode.
The most common way for a mapping to be stale is when a file was deleted,
or renamed. Nothing updates the mappings for deletions yet.
But they can also become stale in other ways. For example a file can
be modified.
So, the mapping is not trusted to be consistent. When we get a key,
only replace symlinks that still point to that key with its content.
When we drop a key, only put back symlinks for files that still have
the direct mode content.
Diffstat (limited to 'Annex')
-rw-r--r-- | Annex/Content.hs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs index feb1d25e6..87ff3f692 100644 --- a/Annex/Content.hs +++ b/Annex/Content.hs @@ -247,8 +247,18 @@ moveAnnex key src = withObjectLoc key storeobject storedirect freezeContent dest freezeContentDir dest ) - storedirect [] = storeobject =<< inRepo (gitAnnexLocation key) - storedirect (dest:fs) = do + storedirect fs = storedirect' =<< liftIO (filterM validsymlink fs) + + validsymlink f = do + tl <- tryIO $ readSymbolicLink f + return $ case tl of + Right l + | isLinkToAnnex l -> + Just key == fileKey (takeFileName l) + _ -> False + + storedirect' [] = storeobject =<< inRepo (gitAnnexLocation key) + storedirect' (dest:fs) = do updateCache key src thawContent src liftIO $ replaceFile dest $ moveFile src @@ -345,9 +355,10 @@ removeAnnex key = withObjectLoc key remove removedirect removeFile file cleanObjectLoc key removedirect fs = do + cache <- recordedCache key removeCache key - mapM_ resetfile fs - resetfile f = do + mapM_ (resetfile cache) fs + resetfile cache f = whenM (compareCache f cache) $ do l <- calcGitLink f key top <- fromRepo Git.repoPath cwd <- liftIO getCurrentDirectory |