1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 06:46:15 +01:00

validate received file length based on given Content-Length. for Bug #656281

This commit is contained in:
Adrian Schröter 2010-11-30 16:39:14 +01:00
parent 94836bcbf7
commit d3188831b9

View File

@ -4495,12 +4495,13 @@ def streamfile(url, http_meth = http_GET, bufsize=8192, data=None, progress_obj=
caller.
"""
f = http_meth.__call__(url, data = data)
import urlparse
cl = f.info().get('Content-Length')
if cl is not None:
cl = int(cl)
if progress_obj:
import urlparse
basename = os.path.basename(urlparse.urlsplit(url)[2])
cl = f.info().get('Content-Length')
if cl is not None:
cl = int(cl)
progress_obj.start(basename=basename, text=text, size=cl)
data = f.read(bufsize)
read = len(data)
@ -4514,6 +4515,9 @@ def streamfile(url, http_meth = http_GET, bufsize=8192, data=None, progress_obj=
progress_obj.end(read)
f.close()
if read != cl:
raise oscerr.OscIOError(None, ('Content-Length is not matching file size for %s: %i vs %i file size' % (url, cl, read)) )
def print_buildlog(apiurl, prj, package, repository, arch, offset = 0):
"""prints out the buildlog on stdout"""