summaryrefslogtreecommitdiff
path: root/Utility
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-08-21 16:05:51 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-08-21 16:05:51 -0400
commit845322a564fe9ff098596f419d06ec9aa748aa2a (patch)
tree451faac8af8c6afab4a97ba980fb456717305cfe /Utility
parenteff764be08164d27307fa1161dfbedc97657afb7 (diff)
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.
Diffstat (limited to 'Utility')
-rw-r--r--Utility/Url.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/Utility/Url.hs b/Utility/Url.hs
index 508b9eeb4..c877583d8 100644
--- a/Utility/Url.hs
+++ b/Utility/Url.hs
@@ -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 = []