update inode cache to cover file even when nothing needs to be done to linkAnnex
This covers the case where multiple files have the same content and are added with git add. Previously only the one that was linked to the annex got its inode cached; now both are.
This commit is contained in:
parent
9fcc5046b3
commit
2bc920e266
1 changed files with 17 additions and 4 deletions
|
@ -27,6 +27,7 @@ module Annex.Content (
|
||||||
linkAnnex,
|
linkAnnex,
|
||||||
linkAnnex',
|
linkAnnex',
|
||||||
LinkAnnexResult(..),
|
LinkAnnexResult(..),
|
||||||
|
unlinkAnnex,
|
||||||
checkedCopyFile,
|
checkedCopyFile,
|
||||||
sendAnnex,
|
sendAnnex,
|
||||||
prepSendAnnex,
|
prepSendAnnex,
|
||||||
|
@ -512,7 +513,6 @@ populatePointerFile k obj f = go =<< isPointerFile f
|
||||||
liftIO $ writeFile f (formatPointer k)
|
liftIO $ writeFile f (formatPointer k)
|
||||||
go _ = return ()
|
go _ = return ()
|
||||||
|
|
||||||
|
|
||||||
{- Hard links a file into .git/annex/objects/, falling back to a copy
|
{- Hard links a file into .git/annex/objects/, falling back to a copy
|
||||||
- if necessary. Does nothing if the object file already exists.
|
- if necessary. Does nothing if the object file already exists.
|
||||||
-
|
-
|
||||||
|
@ -527,17 +527,22 @@ linkAnnex key src = do
|
||||||
modifyContent dest $ linkAnnex' key src dest
|
modifyContent dest $ linkAnnex' key src dest
|
||||||
|
|
||||||
{- Hard links (or copies) src to dest, one of which should be the
|
{- Hard links (or copies) src to dest, one of which should be the
|
||||||
- annex object. -}
|
- annex object. Updates inode cache for src and for dest when it's
|
||||||
|
- changed. -}
|
||||||
linkAnnex' :: Key -> FilePath -> FilePath -> Annex LinkAnnexResult
|
linkAnnex' :: Key -> FilePath -> FilePath -> Annex LinkAnnexResult
|
||||||
linkAnnex' key src dest =
|
linkAnnex' key src dest =
|
||||||
ifM (liftIO $ doesFileExist dest)
|
ifM (liftIO $ doesFileExist dest)
|
||||||
( return LinkAnnexNoop
|
( do
|
||||||
|
Database.Keys.storeInodeCaches key [src]
|
||||||
|
return LinkAnnexNoop
|
||||||
, ifM (linkAnnex'' key src dest)
|
, ifM (linkAnnex'' key src dest)
|
||||||
( do
|
( do
|
||||||
thawContent dest
|
thawContent dest
|
||||||
Database.Keys.storeInodeCaches key [dest, src]
|
Database.Keys.storeInodeCaches key [dest, src]
|
||||||
return LinkAnnexOk
|
return LinkAnnexOk
|
||||||
, return LinkAnnexFailed
|
, do
|
||||||
|
Database.Keys.storeInodeCaches key [src]
|
||||||
|
return LinkAnnexFailed
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -560,6 +565,14 @@ linkAnnex'' key src dest = catchBoolIO $ do
|
||||||
copy
|
copy
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
{- Removes the annex object file for a key. Lowlevel. -}
|
||||||
|
unlinkAnnex :: Key -> Annex ()
|
||||||
|
unlinkAnnex key = do
|
||||||
|
obj <- calcRepo $ gitAnnexLocation key
|
||||||
|
modifyContent obj $ do
|
||||||
|
secureErase obj
|
||||||
|
liftIO $ nukeFile obj
|
||||||
|
|
||||||
{- Checks disk space before copying. -}
|
{- Checks disk space before copying. -}
|
||||||
checkedCopyFile :: Key -> FilePath -> FilePath -> Annex Bool
|
checkedCopyFile :: Key -> FilePath -> FilePath -> Annex Bool
|
||||||
checkedCopyFile key src dest = catchBoolIO $
|
checkedCopyFile key src dest = catchBoolIO $
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue