Delete empty downloaded file when wget fails, to work around reported resume failure.

<RichiH> i richih@eudyptes (git)-[master] ~git/debconf-share/debconf13/photos/chrysn % rm /home/richih/work/git/debconf-share/.git/annex/tmp/SHA256E-s3044235--693b74fcb12db06b5e79a8b99d03e2418923866506ee62d24a4e9ae8c5236758.JPG
<RichiH> richih@eudyptes (git)-[master] ~git/debconf-share/debconf13/photos/chrysn % git annex get P8060008.JPG
<RichiH> get P8060008.JPG (from website...) --2013-08-21 21:42:45--  http://annex.debconf.org/debconf-share/.git//annex/objects/1a4/67d/SHA256E-s3044235--693b74fcb12db06b5e79a8b99d03e2418923866506ee62d24a4e9ae8c5236758.JPG/SHA256E-s3044235--693b74fcb12db06b5e79a8b99d03e2418923866506ee62d24a4e9ae8c5236758.JPG
<RichiH> Resolving annex.debconf.org (annex.debconf.org)... 5.153.231.227, 2001:41c8:1000:19::227:2
<RichiH> Connecting to annex.debconf.org (annex.debconf.org)|5.153.231.227|:80... connected.
<RichiH> HTTP request sent, awaiting response... 404 Not Found
<RichiH> 2013-08-21 21:42:45 ERROR 404: Not Found.
<RichiH> File `/home/richih/work/git/debconf-share/.git/annex/tmp/SHA256E-s3044235--693b74fcb12db06b5e79a8b99d03e2418923866506ee62d24a4e9ae8c5236758.JPG' already there; not retrieving.
<RichiH>   Unable to access these remotes: website
<RichiH>   Try making some of these repositories available:
<RichiH>    3e0356ac-0743-11e3-83a5-1be63124a102 -- website (annex.debconf.org)
<RichiH>     a7495021-9f2d-474e-80c7-34d29d09fec6 -- chrysn@hephaistos:~/data/projects/debconf13/debconf-share
<RichiH>     eb8990f7-84cd-4e6b-b486-a5e71efbd073 -- joeyh passport usb drive
<RichiH>     f415f118-f428-4c68-be66-c91501da3a93 -- joeyh laptop
<RichiH> failed
<RichiH> git-annex: get: 1 failed
<RichiH> richih@eudyptes (git)-[master] ~git/debconf-share/debconf13/photos/chrysn %

I was not able to reproduce the failure, but I did reproduce that
wget -O http://404/ results in an empty file being written.
This commit is contained in:
Joey Hess 2013-08-21 16:05:51 -04:00
parent dc0992f7e2
commit 98886e3fbf
2 changed files with 12 additions and 2 deletions

View file

@ -118,8 +118,16 @@ download' quiet url headers options file =
- downloaded before the resume. -}
curl = go "curl" $ headerparams ++ quietopt "-s" ++
[Params "-f -L -C - -# -o"]
go cmd opts = boolSystem cmd $
options++opts++[File file, File url]
go cmd opts = do
ok <- boolSystem cmd $
options++opts++[File file, File url]
-- wget sometimes leaves behind an empty file on failure;
-- remove this as it sometimes interferes with a re-download
unless ok $ do
size <- catchMaybeIO $ fileSize <$> getFileStatus file
when (size == Just 0) $
removeFile file
return ok
quietopt s
| quiet = [Param s]
| otherwise = []

2
debian/changelog vendored
View file

@ -7,6 +7,8 @@ git-annex (4.20130816) UNRELEASED; urgency=low
* import: Add options to control handling of duplicate files:
--duplicate, --deduplicate, and --clean-duplicates
* mirror: New command, makes two repositories contain the same set of files.
* Delete empty downloaded file when wget fails, to work around reported
resume failure.
-- Joey Hess <joeyh@debian.org> Thu, 15 Aug 2013 15:47:52 +0200