diff options
author | Joey Hess <joey@kitenet.net> | 2013-05-06 12:43:03 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-05-06 12:43:03 -0400 |
commit | 7d345fcb307cfecb5fa834a0b17be01e4e6f5df8 (patch) | |
tree | fd8026d85591ac9aa1a310171b84a4ae9369abdc /Annex/Direct.hs | |
parent | eea511d1f3a6a77f541db0a61c96ed1bd461d0d0 (diff) |
direct: Fix a bug that could cause some files to be left in indirect mode.
It's possible for files in indirect mode to have a direct mode mapping
file. Probably from when they were in direct mode. In this case,
toDirectGen tried to copy the content from the direct mode file that the
mapping said had it. But, being in indirect mode, it didn't really have the
content. So it did nothing. This fix makes it always move the content from
.git/annex/objects/ when it's there.
Diffstat (limited to 'Annex/Direct.hs')
-rw-r--r-- | Annex/Direct.hs | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/Annex/Direct.hs b/Annex/Direct.hs index f8bdaebb3..596c90994 100644 --- a/Annex/Direct.hs +++ b/Annex/Direct.hs @@ -182,25 +182,27 @@ toDirect k f = fromMaybe noop =<< toDirectGen k f toDirectGen :: Key -> FilePath -> Annex (Maybe (Annex ())) toDirectGen k f = do loc <- calcRepo $ gitAnnexLocation k - absf <- liftIO $ absPath f - locs <- filter (/= absf) <$> addAssociatedFile k f - case locs of - [] -> ifM (liftIO $ doesFileExist loc) - ( return $ Just $ do - {- Move content from annex to direct file. -} - thawContentDir loc - updateInodeCache k loc - thawContent loc - replaceFile f $ liftIO . moveFile loc - , return Nothing - ) - (loc':_) -> ifM (isNothing <$> getAnnexLinkTarget loc') - {- Another direct file has the content; copy it. -} - ( return $ Just $ + ifM (liftIO $ doesFileExist loc) + ( fromindirect loc + , fromdirect + ) + where + fromindirect loc = return $ Just $ do + {- Move content from annex to direct file. -} + thawContentDir loc + updateInodeCache k loc + thawContent loc + replaceFile f $ liftIO . moveFile loc + fromdirect = do + {- Copy content from another direct file. -} + absf <- liftIO $ absPath f + locs <- filterM (\loc -> isNothing <$> getAnnexLinkTarget loc) =<< + (filter (/= absf) <$> addAssociatedFile k f) + case locs of + (loc:_) -> return $ Just $ replaceFile f $ - liftIO . void . copyFileExternal loc' - , return Nothing - ) + liftIO . void . copyFileExternal loc + _ -> return Nothing {- Removes a direct mode file, while retaining its content. -} removeDirect :: Key -> FilePath -> Annex () |