Avoid deleting temp files when rsync fails.
This commit is contained in:
parent
b9320ee1d5
commit
2fba1ba40d
3 changed files with 16 additions and 12 deletions
25
Core.hs
25
Core.hs
|
@ -29,7 +29,7 @@ import Messages
|
||||||
|
|
||||||
{- Runs a list of Annex actions. Catches IO errors and continues
|
{- Runs a list of Annex actions. Catches IO errors and continues
|
||||||
- (but explicitly thrown errors terminate the whole command).
|
- (but explicitly thrown errors terminate the whole command).
|
||||||
- Propigates an overall error status at the end.
|
- Runs shutdown and propigates an overall error status at the end.
|
||||||
-}
|
-}
|
||||||
tryRun :: AnnexState -> [Annex Bool] -> IO ()
|
tryRun :: AnnexState -> [Annex Bool] -> IO ()
|
||||||
tryRun state actions = tryRun' state 0 actions
|
tryRun state actions = tryRun' state 0 actions
|
||||||
|
@ -42,7 +42,8 @@ tryRun' state errnum (a:as) = do
|
||||||
tryRun' state (errnum + 1) as
|
tryRun' state (errnum + 1) as
|
||||||
Right (True,state') -> tryRun' state' errnum as
|
Right (True,state') -> tryRun' state' errnum as
|
||||||
Right (False,state') -> tryRun' state' (errnum + 1) as
|
Right (False,state') -> tryRun' state' (errnum + 1) as
|
||||||
tryRun' _ errnum [] =
|
tryRun' state errnum [] = do
|
||||||
|
_ <- try $ Annex.run state $ shutdown errnum
|
||||||
when (errnum > 0) $ error $ show errnum ++ " failed"
|
when (errnum > 0) $ error $ show errnum ++ " failed"
|
||||||
|
|
||||||
{- Actions to perform each time ran. -}
|
{- Actions to perform each time ran. -}
|
||||||
|
@ -52,20 +53,22 @@ startup = do
|
||||||
return True
|
return True
|
||||||
|
|
||||||
{- When git-annex is done, it runs this. -}
|
{- When git-annex is done, it runs this. -}
|
||||||
shutdown :: Annex Bool
|
shutdown :: Integer -> Annex Bool
|
||||||
shutdown = do
|
shutdown errnum = do
|
||||||
q <- Annex.queueGet
|
q <- Annex.queueGet
|
||||||
unless (q == GitQueue.empty) $ do
|
unless (q == GitQueue.empty) $ do
|
||||||
showSideAction "Recording state in git..."
|
showSideAction "Recording state in git..."
|
||||||
Annex.queueRun
|
Annex.queueRun
|
||||||
|
|
||||||
-- clean up any files left in the temp directory, but leave
|
-- If nothing failed, clean up any files left in the temp directory,
|
||||||
-- the tmp directory itself
|
-- but leave the directory itself. If something failed, temp files
|
||||||
g <- Annex.gitRepo
|
-- are left behind to allow resuming on re-run.
|
||||||
let tmp = annexTmpLocation g
|
when (errnum == 0) $ do
|
||||||
exists <- liftIO $ doesDirectoryExist tmp
|
g <- Annex.gitRepo
|
||||||
when exists $ liftIO $ removeDirectoryRecursive tmp
|
let tmp = annexTmpLocation g
|
||||||
liftIO $ createDirectoryIfMissing True tmp
|
exists <- liftIO $ doesDirectoryExist tmp
|
||||||
|
when exists $ liftIO $ removeDirectoryRecursive tmp
|
||||||
|
liftIO $ createDirectoryIfMissing True tmp
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -3,6 +3,7 @@ git-annex (0.11) UNRELEASED; urgency=low
|
||||||
* If available, rsync will be used for file transfers from remote
|
* If available, rsync will be used for file transfers from remote
|
||||||
repositories. This allows resuming interrupted transfers.
|
repositories. This allows resuming interrupted transfers.
|
||||||
* Added remote.annex-rsync-options.
|
* Added remote.annex-rsync-options.
|
||||||
|
* Avoid deleting temp files when rsync fails.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Thu, 02 Dec 2010 16:54:12 -0400
|
-- Joey Hess <joeyh@debian.org> Thu, 02 Dec 2010 16:54:12 -0400
|
||||||
|
|
||||||
|
|
|
@ -20,4 +20,4 @@ main = do
|
||||||
gitrepo <- Git.repoFromCwd
|
gitrepo <- Git.repoFromCwd
|
||||||
state <- Annex.new gitrepo allBackends
|
state <- Annex.new gitrepo allBackends
|
||||||
(configure, actions) <- parseCmd args state
|
(configure, actions) <- parseCmd args state
|
||||||
tryRun state $ [startup, upgrade] ++ configure ++ actions ++ [shutdown]
|
tryRun state $ [startup, upgrade] ++ configure ++ actions
|
||||||
|
|
Loading…
Reference in a new issue