Revert "Clean up direct mode cache and mapping info when dropping keys."

This reverts commit 57780cb3a4.

This was buggy, it caused the direct mode cache to be lost when dropping
keys, so when the file is gotten back, it's stored in indirect mode.

Note to self: Do not attempt bug fixes at 6 am!
This commit is contained in:
Joey Hess 2013-02-15 16:37:57 -04:00
parent 80fa144d79
commit 5a8fb26d0a
4 changed files with 11 additions and 14 deletions

View file

@ -28,7 +28,6 @@ module Annex.Content (
freezeContent, freezeContent,
thawContent, thawContent,
replaceFile, replaceFile,
cleanObjectLoc,
) where ) where
import System.IO.Unsafe (unsafeInterleaveIO) import System.IO.Unsafe (unsafeInterleaveIO)
@ -330,12 +329,9 @@ withObjectLoc key indirect direct = ifM isDirect
cleanObjectLoc :: Key -> Annex () cleanObjectLoc :: Key -> Annex ()
cleanObjectLoc key = do cleanObjectLoc key = do
file <- inRepo $ gitAnnexLocation key file <- inRepo $ gitAnnexLocation key
let dir = parentDir file
unlessM crippledFileSystem $ unlessM crippledFileSystem $
void $ liftIO $ catchMaybeIO $ allowWrite dir void $ liftIO $ catchMaybeIO $ allowWrite $ parentDir file
void $ liftIO $ catchMaybeIO $ do liftIO $ removeparents file (3 :: Int)
removeDirectoryRecursive dir
liftIO $ removeparents dir (2 :: Int)
where where
removeparents _ 0 = noop removeparents _ 0 = noop
removeparents file n = do removeparents file n = do
@ -357,8 +353,8 @@ removeAnnex key = withObjectLoc key remove removedirect
cleanObjectLoc key cleanObjectLoc key
removedirect fs = do removedirect fs = do
cache <- recordedInodeCache key cache <- recordedInodeCache key
removeInodeCache key
mapM_ (resetfile cache) fs mapM_ (resetfile cache) fs
cleanObjectLoc key
resetfile cache f = whenM (liftIO $ compareInodeCache f cache) $ do resetfile cache f = whenM (liftIO $ compareInodeCache f cache) $ do
l <- calcGitLink f key l <- calcGitLink f key
top <- fromRepo Git.repoPath top <- fromRepo Git.repoPath

View file

@ -15,6 +15,7 @@ module Annex.Content.Direct (
updateInodeCache, updateInodeCache,
writeInodeCache, writeInodeCache,
compareInodeCache, compareInodeCache,
removeInodeCache,
toInodeCache, toInodeCache,
) where ) where
@ -119,5 +120,11 @@ writeInodeCache key cache = withInodeCacheFile key $ \f -> do
createContentDir f createContentDir f
liftIO $ writeFile f $ showInodeCache cache liftIO $ writeFile f $ showInodeCache cache
{- Removes an inode cache. -}
removeInodeCache :: Key -> Annex ()
removeInodeCache key = withInodeCacheFile key $ \f -> do
createContentDir f -- also thaws directory
liftIO $ nukeFile f
withInodeCacheFile :: Key -> (FilePath -> Annex a) -> Annex a withInodeCacheFile :: Key -> (FilePath -> Annex a) -> Annex a
withInodeCacheFile key a = a =<< inRepo (gitAnnexInodeCache key) withInodeCacheFile key a = a =<< inRepo (gitAnnexInodeCache key)

View file

@ -60,10 +60,7 @@ performLocal key numcopies knownpresentremote = lockContent key $ do
untrusteduuids <- trustGet UnTrusted untrusteduuids <- trustGet UnTrusted
let tocheck = Remote.remotesWithoutUUID remotes (trusteduuids'++untrusteduuids) let tocheck = Remote.remotesWithoutUUID remotes (trusteduuids'++untrusteduuids)
stopUnless (canDropKey key numcopies trusteduuids' tocheck []) $ do stopUnless (canDropKey key numcopies trusteduuids' tocheck []) $ do
whenM (inAnnex key) $ whenM (inAnnex key) $ removeAnnex key
removeAnnex key
{- Clean up stale direct mode files that may exist. -}
cleanObjectLoc key
next $ cleanupLocal key next $ cleanupLocal key
performRemote :: Key -> Maybe Int -> Remote -> CommandPerform performRemote :: Key -> Maybe Int -> Remote -> CommandPerform

View file

@ -56,6 +56,3 @@ What version of git-annex are you using? On what operating system?
git-annex: 3.20130124 git-annex: 3.20130124
Debian: sid 2013-02-01 Debian: sid 2013-02-01
> unused being confused by stale data left when switching from direct mode.
> I've made this be cleaned up. [[done]] --[[Joey]]