From 1a390558e9fb5ab18cfecec27f4370cac89c1c6c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Dunand?= <aurelien.dunand@smartjog.com>
Date: Tue, 2 Aug 2011 15:43:32 +0200
Subject: [PATCH] Copy file from http without read it in one time

When huge payload was read, it could cause Out Of Memory error.
Use istools copyfileobj for read chunk by chunk.

Signed-off-by: Seblu <sebastien.luttringer@smartjog.com>
---
 installsystems/tools.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/installsystems/tools.py b/installsystems/tools.py
index f54b116..30b06d1 100644
--- a/installsystems/tools.py
+++ b/installsystems/tools.py
@@ -60,7 +60,7 @@ def copy(source, destination, uid=None, gid=None, mode=None, timeout=None):
     elif (stype == "http" or stype == "ftp") and dtype == "file":
         f_dest = open(destination, "w")
         f_source = urllib2.urlopen(source, timeout=timeout)
-        f_dest.write(f_source.read())
+        copyfileobj(f_source, f_dest)
     elif stype == "file" and dtype == "":
         raise NotImplementedError
     else:
-- 
GitLab