direct: Avoid leaving file content in misctemp if interrupted.
This commit is contained in:
parent
aa31a7182e
commit
bb6cec3461
4 changed files with 14 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -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 <joeyh@debian.org> Mon, 21 Jul 2014 14:41:26 -0400
|
||||
|
||||
|
|
|
@ -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"]
|
||||
|
|
Loading…
Reference in a new issue