Update working tree files fully atomically
This avoids commit churn by the assistant when eg, replacing a file with a symlink. But, just as importantly, it prevents the working tree being left with a deleted file if git-annex, or perhaps the whole system, crashes at the wrong time. (It also probably avoids confusing displays in file managers.)
This commit is contained in:
parent
8c52b20cc7
commit
38d61f934d
8 changed files with 34 additions and 21 deletions
|
@ -153,8 +153,7 @@ mergeDirectCleanup d oldsha newsha = do
|
|||
- Symlinks are replaced with their content, if it's available. -}
|
||||
movein k f = do
|
||||
l <- calcGitLink f k
|
||||
replaceFile f $
|
||||
makeAnnexLink l
|
||||
replaceFile f $ makeAnnexLink l
|
||||
toDirect k f
|
||||
|
||||
{- Any new, modified, or renamed files were written to the temp
|
||||
|
@ -179,15 +178,14 @@ toDirectGen k f = do
|
|||
{- Move content from annex to direct file. -}
|
||||
updateInodeCache k loc
|
||||
thawContent loc
|
||||
replaceFile f $
|
||||
liftIO . moveFile loc
|
||||
replaceFile f $ liftIO . moveFile loc
|
||||
, return Nothing
|
||||
)
|
||||
(loc':_) -> ifM (isNothing <$> getAnnexLinkTarget loc')
|
||||
{- Another direct file has the content; copy it. -}
|
||||
( return $ Just $
|
||||
replaceFile f $
|
||||
void . liftIO . copyFileExternal loc'
|
||||
liftIO . void . copyFileExternal loc'
|
||||
, return Nothing
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue