From 845322a564fe9ff098596f419d06ec9aa748aa2a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 21 Aug 2013 16:05:51 -0400 Subject: Delete empty downloaded file when wget fails, to work around reported resume failure. 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@eudyptes (git)-[master] ~git/debconf-share/debconf13/photos/chrysn % git annex get P8060008.JPG 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 Resolving annex.debconf.org (annex.debconf.org)... 5.153.231.227, 2001:41c8:1000:19::227:2 Connecting to annex.debconf.org (annex.debconf.org)|5.153.231.227|:80... connected. HTTP request sent, awaiting response... 404 Not Found 2013-08-21 21:42:45 ERROR 404: Not Found. File `/home/richih/work/git/debconf-share/.git/annex/tmp/SHA256E-s3044235--693b74fcb12db06b5e79a8b99d03e2418923866506ee62d24a4e9ae8c5236758.JPG' already there; not retrieving. Unable to access these remotes: website Try making some of these repositories available: 3e0356ac-0743-11e3-83a5-1be63124a102 -- website (annex.debconf.org) a7495021-9f2d-474e-80c7-34d29d09fec6 -- chrysn@hephaistos:~/data/projects/debconf13/debconf-share eb8990f7-84cd-4e6b-b486-a5e71efbd073 -- joeyh passport usb drive f415f118-f428-4c68-be66-c91501da3a93 -- joeyh laptop failed git-annex: get: 1 failed 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. --- Utility/Url.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'Utility') 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 = [] -- cgit v1.2.3