Commit fe7d5b21 authored by Sebastien Luttringer's avatar Sebastien Luttringer
Browse files

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

parent 147cab8a
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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()
+1 −1
Original line number Diff line number Diff line
@@ -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))