fix transfer log cleanup crash

Avoid crashing when "git annex get" fails to download from one location,
and falls back to downloading from a second location.

The problem is that git annex get calls download recursively from within
itself if the first download attempt fails. So the first time through, it
writes a transfer info file, which is then overwritten on the second,
recursive call. Then on cleanup, it tries to delete the file twice, which
of course doesn't work.

Fixed both by not crashing if the transfer file is removed, and by
changing Get to not run download recursively like that. It's the only
thing that did so, and it just seems like a bad idea.
This commit is contained in:
Joey Hess 2012-08-07 13:27:50 -04:00
parent 96d0a36f85
commit 2a9077f4e9
4 changed files with 10 additions and 7 deletions

View file

@ -65,7 +65,8 @@ getKeyFile key file dest = dispatch =<< Remote.keyPossibilities key
| Remote.hasKeyCheap r =
either (const False) id <$> Remote.hasKey r key
| otherwise = return True
docopy r continue = download (Remote.uuid r) key (Just file) $ do
showAction $ "from " ++ Remote.name r
ifM (Remote.retrieveKeyFile r key (Just file) dest)
( return True , continue)
docopy r continue = do
ok <- download (Remote.uuid r) key (Just file) $ do
showAction $ "from " ++ Remote.name r
Remote.retrieveKeyFile r key (Just file) dest
if ok then return ok else continue

View file

@ -98,8 +98,8 @@ transfer t file a = do
writeFile tfile $ writeTransferInfo info
return fd
cleanup tfile fd = do
removeFile tfile
removeFile $ transferLockFile tfile
void $ tryIO $ removeFile tfile
void $ tryIO $ removeFile $ transferLockFile tfile
closeFd fd
{- If a transfer is still running, returns its TransferInfo. -}

2
debian/changelog vendored
View file

@ -3,6 +3,8 @@ git-annex (3.20120722) UNRELEASED; urgency=low
* initremote: Avoid recording remote's description before checking
that its config is valid.
* unused, status: Avoid crashing when ran in bare repo.
* Avoid crashing when "git annex get" fails to download from one
location, and falls back to downloading from a second location.
-- Joey Hess <joeyh@debian.org> Fri, 27 Jul 2012 21:04:47 -0400

View file

@ -1,5 +1,5 @@
Name: git-annex
Version: 3.20120721
Version: 3.20120722
Cabal-Version: >= 1.8
License: GPL
Maintainer: Joey Hess <joey@kitenet.net>