All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fetch2/wget: Check downloaded file isn't zero size
@ 2014-01-21 22:31 Richard Purdie
  0 siblings, 0 replies; only message in thread
From: Richard Purdie @ 2014-01-21 22:31 UTC (permalink / raw)
  To: bitbake-devel



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 <richard.purdie@linuxfoundation.org>

diff --git a/lib/bb/fetch2/wget.py b/lib/bb/fetch2/wget.py
index 0073201..7cd25a5 100644
--- a/lib/bb/fetch2/wget.py
+++ b/lib/bb/fetch2/wget.py
@@ -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):




^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-01-21 22:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-21 22:31 [PATCH] fetch2/wget: Check downloaded file isn't zero size Richard Purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.