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
|
void $ addAssociatedFile k f
|
||||||
modifyContent loc $ do
|
modifyContent loc $ do
|
||||||
thawContent loc
|
thawContent loc
|
||||||
replaceFileOr f
|
liftIO (replaceFileFrom loc f)
|
||||||
(liftIO . moveFile loc)
|
`catchIO` (\_ -> freezeContent loc)
|
||||||
$ \tmp -> do -- rollback
|
|
||||||
liftIO (moveFile tmp loc)
|
|
||||||
freezeContent loc
|
|
||||||
fromdirect loc = do
|
fromdirect loc = do
|
||||||
replaceFile f $
|
replaceFile f $
|
||||||
liftIO . void . copyFileExternal loc
|
liftIO . void . copyFileExternal loc
|
||||||
|
|
|
@ -39,7 +39,12 @@ replaceFileOr file action rollback = do
|
||||||
return tmpfile
|
return tmpfile
|
||||||
go tmpfile = do
|
go tmpfile = do
|
||||||
action tmpfile
|
action tmpfile
|
||||||
liftIO $ catchIO (rename tmpfile file) (fallback tmpfile)
|
liftIO $ replaceFileFrom tmpfile file
|
||||||
fallback tmpfile _ = do
|
|
||||||
createDirectoryIfMissing True $ parentDir file
|
replaceFileFrom :: FilePath -> FilePath -> IO ()
|
||||||
moveFile tmpfile file
|
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.
|
subdirectory in the key name.
|
||||||
* S3, Glacier, WebDAV: Fix bug that prevented accessing the creds
|
* S3, Glacier, WebDAV: Fix bug that prevented accessing the creds
|
||||||
when the repository was configured with encryption=shared embedcreds=yes.
|
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
|
-- 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/]]
|
* [[forum/Cleaning_up_after_aborted_sync_in_direct_mode/]]
|
||||||
* [[bugs/failure_to_return_to_indirect_mode_on_usb/]]
|
* [[bugs/failure_to_return_to_indirect_mode_on_usb/]]
|
||||||
* [[forum/git-status_typechange_in_direct_mode/]]
|
* [[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