diff options
author | 2014-07-10 14:15:46 -0400 | |
---|---|---|
committer | 2014-07-10 14:15:46 -0400 | |
commit | 0ecf84090ba1d59bc3d0064ac2a87874252971e4 (patch) | |
tree | 8bcd342cfb0b9763581b61ce3b331d7ecc9a7a9b /Annex/Direct.hs | |
parent | 9d6fa46120e7bf69f4e19418c949020f69845b02 (diff) |
direct: Fix handling of case where a work tree subdirectory cannot be written to due to permissions.
Running `git annex direct` would cause loss of data, because the object
was moved to a temp file, which it then tried to replace the work tree file
with, and on failure, the temp file got deleted. Now it's instead moved
back into the annex object location.
Diffstat (limited to 'Annex/Direct.hs')
-rw-r--r-- | Annex/Direct.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Annex/Direct.hs b/Annex/Direct.hs index fdc67a720..e6b941e0f 100644 --- a/Annex/Direct.hs +++ b/Annex/Direct.hs @@ -354,7 +354,11 @@ toDirectGen k f = do void $ addAssociatedFile k f modifyContent loc $ do thawContent loc - replaceFile f $ liftIO . moveFile loc + replaceFileOr f + (liftIO . moveFile loc) + $ \tmp -> do -- rollback + liftIO (moveFile tmp loc) + freezeContent loc fromdirect loc = do replaceFile f $ liftIO . void . copyFileExternal loc |