diff --git a/Annex/Direct.hs b/Annex/Direct.hs index 3745993698..7b91cc342e 100644 --- a/Annex/Direct.hs +++ b/Annex/Direct.hs @@ -353,11 +353,8 @@ toDirectGen k f = do void $ addAssociatedFile k f modifyContent loc $ do thawContent loc - replaceFileOr f - (liftIO . moveFile loc) - $ \tmp -> do -- rollback - liftIO (moveFile tmp loc) - freezeContent loc + liftIO (replaceFileFrom loc f) + `catchIO` (\_ -> freezeContent loc) fromdirect loc = do replaceFile f $ liftIO . void . copyFileExternal loc diff --git a/Annex/ReplaceFile.hs b/Annex/ReplaceFile.hs index 8cb0cc6da7..9700d4b60c 100644 --- a/Annex/ReplaceFile.hs +++ b/Annex/ReplaceFile.hs @@ -39,7 +39,12 @@ replaceFileOr file action rollback = do return tmpfile go tmpfile = do action tmpfile - liftIO $ catchIO (rename tmpfile file) (fallback tmpfile) - fallback tmpfile _ = do - createDirectoryIfMissing True $ parentDir file - moveFile tmpfile file + liftIO $ replaceFileFrom tmpfile file + +replaceFileFrom :: FilePath -> FilePath -> IO () +replaceFileFrom src dest = go `catchIO` fallback + where + go = moveFile src dest + fallback _ = do + createDirectoryIfMissing True $ parentDir dest + go diff --git a/debian/changelog b/debian/changelog index b1d53a8415..eaa36b3621 100644 --- a/debian/changelog +++ b/debian/changelog @@ -35,6 +35,7 @@ git-annex (5.20140718) UNRELEASED; urgency=medium subdirectory in the key name. * S3, Glacier, WebDAV: Fix bug that prevented accessing the creds when the repository was configured with encryption=shared embedcreds=yes. + * direct: Avoid leaving file content in misctemp if interrupted. -- Joey Hess Mon, 21 Jul 2014 14:41:26 -0400 diff --git a/doc/bugs/direct_command_leaves_repository_inconsistent_if_interrupted.mdwn b/doc/bugs/direct_command_leaves_repository_inconsistent_if_interrupted.mdwn index 0d81c67789..c19db9727d 100644 --- a/doc/bugs/direct_command_leaves_repository_inconsistent_if_interrupted.mdwn +++ b/doc/bugs/direct_command_leaves_repository_inconsistent_if_interrupted.mdwn @@ -41,3 +41,5 @@ Similar issues and discussions: * [[forum/Cleaning_up_after_aborted_sync_in_direct_mode/]] * [[bugs/failure_to_return_to_indirect_mode_on_usb/]] * [[forum/git-status_typechange_in_direct_mode/]] + +[[!meta title="git annex lock --force deletes only copy of content after interrupted switch to direct mode"]