From fe7d5b215001424504331d5e2421c0a0fd1327a0 Mon Sep 17 00:00:00 2001
From: Sebastien Luttringer <sebastien.luttringer@smartjog.com>
Date: Thu, 13 Oct 2011 16:46:17 +0200
Subject: [PATCH] use PipeFile.consume() in place of shutil.copyfileobj

---
 installsystems/image.py      | 6 +++---
 installsystems/repository.py | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/installsystems/image.py b/installsystems/image.py
index fbef631..8fb8d39 100644
--- a/installsystems/image.py
+++ b/installsystems/image.py
@@ -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()
diff --git a/installsystems/repository.py b/installsystems/repository.py
index bcf7d29..8c02c2d 100644
--- a/installsystems/repository.py
+++ b/installsystems/repository.py
@@ -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))
-- 
GitLab