Skip to content
Snippets Groups Projects
Commit fe7d5b21 authored by Sebastien Luttringer's avatar Sebastien Luttringer
Browse files

use PipeFile.consume() in place of shutil.copyfileobj

parent 147cab8a
No related branches found
No related tags found
No related merge requests found
......@@ -415,7 +415,7 @@ class PackageImage(Image):
else:
fileobj = PipeFile(mode="r", fileobj=fileobj)
memfile = cStringIO.StringIO()
shutil.copyfileobj(fileobj, memfile)
fileobj.consume(memfile)
# close source
fileobj.close()
# get donwloaded size and md5
......@@ -558,7 +558,7 @@ class PackageImage(Image):
raise Exception("Downloading image %s failed: Invalid announced size" % self.name)
# open destination
fd = open(self.filename, "wb")
shutil.copyfileobj(fs, fd)
fs.consume(fd)
fs.close()
fd.close()
if self.size != fs.consumed_size:
......@@ -798,7 +798,7 @@ class Payload(object):
if fs.size is not None and self.size != fs.size:
raise Exception("Downloading payload %s failed: Invalid announced size" % self.name)
fd = open(dest, "wb")
shutil.copyfileobj(fs, fd)
fs.consume(fd)
# closing fo
fs.close()
fd.close()
......
......@@ -391,7 +391,7 @@ class Repository(object):
memfile = cStringIO.StringIO()
try:
fo = PipeFile(path, "r")
shutil.copyfileobj(fo, memfile)
fo.consume(memfile)
fo.close()
except Exception as e:
raise Exception("Loading image %s v%s failed: %s" % (name, version, e))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment