Patchwork [bitbake-devel] fetch2/wget: Check downloaded file isn't zero size

mail settings
Submitter Richard Purdie
Date Jan. 21, 2014, 10:31 p.m.
Message ID <1390343468.874.123.camel@ted>
Download mbox | patch
Permalink /patch/65391/
State New
Headers show


Richard Purdie - Jan. 21, 2014, 10:31 p.m.
I can't think of a reason we'd download zero sized files however there are
reasons zero length files can accidently make it onto source mirrors.

This check allows us to ignore the broken files and switch to another
mirror rather than fail with odd checksum failures.

Signed-off-by: Richard Purdie <>


diff --git a/lib/bb/fetch2/ b/lib/bb/fetch2/
index 0073201..7cd25a5 100644
--- a/lib/bb/fetch2/
+++ b/lib/bb/fetch2/
@@ -91,6 +91,10 @@  class Wget(FetchMethod):
         if not os.path.exists(ud.localpath) and not checkonly:
             raise FetchError("The fetch command returned success for url %s but %s doesn't exist?!" % (uri, ud.localpath), uri)
+        if not checkonly and os.path.getsize(ud.localpath) == 0:
+            os.remove(ud.localpath)
+            raise FetchError("The fetch of %s resulted in a zero size file?! Deleting and failing since this isn't right." % (uri), uri)
         return True
     def checkstatus(self, ud, d):