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.
This commit is contained in:
parent
9174d4449a
commit
af3a25ee03
3 changed files with 22 additions and 4 deletions
|
@ -247,8 +247,18 @@ moveAnnex key src = withObjectLoc key storeobject storedirect
|
||||||
freezeContent dest
|
freezeContent dest
|
||||||
freezeContentDir dest
|
freezeContentDir dest
|
||||||
)
|
)
|
||||||
storedirect [] = storeobject =<< inRepo (gitAnnexLocation key)
|
storedirect fs = storedirect' =<< liftIO (filterM validsymlink fs)
|
||||||
storedirect (dest:fs) = do
|
|
||||||
|
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
|
updateCache key src
|
||||||
thawContent src
|
thawContent src
|
||||||
liftIO $ replaceFile dest $ moveFile src
|
liftIO $ replaceFile dest $ moveFile src
|
||||||
|
@ -345,9 +355,10 @@ removeAnnex key = withObjectLoc key remove removedirect
|
||||||
removeFile file
|
removeFile file
|
||||||
cleanObjectLoc key
|
cleanObjectLoc key
|
||||||
removedirect fs = do
|
removedirect fs = do
|
||||||
|
cache <- recordedCache key
|
||||||
removeCache key
|
removeCache key
|
||||||
mapM_ resetfile fs
|
mapM_ (resetfile cache) fs
|
||||||
resetfile f = do
|
resetfile cache f = whenM (compareCache f cache) $ do
|
||||||
l <- calcGitLink f key
|
l <- calcGitLink f key
|
||||||
top <- fromRepo Git.repoPath
|
top <- fromRepo Git.repoPath
|
||||||
cwd <- liftIO getCurrentDirectory
|
cwd <- liftIO getCurrentDirectory
|
||||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -9,6 +9,7 @@ git-annex (3.20130125) UNRELEASED; urgency=low
|
||||||
and other tasks.
|
and other tasks.
|
||||||
* assistant: Ignore .DS_Store on OSX.
|
* assistant: Ignore .DS_Store on OSX.
|
||||||
* assistant: Fix location log when adding new file in direct mode.
|
* assistant: Fix location log when adding new file in direct mode.
|
||||||
|
* Deal with stale mappings for deleted file in direct mode.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Sat, 26 Jan 2013 15:48:40 +1100
|
-- Joey Hess <joeyh@debian.org> Sat, 26 Jan 2013 15:48:40 +1100
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,12 @@ is converted to a real file when it becomes present.
|
||||||
* kqueue does not deliver an event when an existing file is modified.
|
* kqueue does not deliver an event when an existing file is modified.
|
||||||
This doesn't affect OSX, which uses FSEvents now, but it makes direct
|
This doesn't affect OSX, which uses FSEvents now, but it makes direct
|
||||||
mode assistant not 100% on other BSD's.
|
mode assistant not 100% on other BSD's.
|
||||||
|
* The mapping is not updated when files are deleted (or for the deletion
|
||||||
|
part of a rename). So it can contain old filenames that are no longer in
|
||||||
|
use. Code that uses the mapping has to take care to check that the
|
||||||
|
files they refer to exists, which is a good idea anyway. But,
|
||||||
|
it would be good to at some point update the mappings to remove deleted
|
||||||
|
files (fsck does this FWIW).
|
||||||
|
|
||||||
## done
|
## done
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue