From: Zac Medico Date: Mon, 25 Jun 2007 04:50:48 +0000 (-0000) Subject: Fix file_get_lib() so it behaves the same way with sftp as it does with other protoco... X-Git-Tag: v2.1.3~144 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4fbcaef8d7ff602606bcf26d1c3ce1a30da6c9a4;p=portage.git Fix file_get_lib() so it behaves the same way with sftp as it does with other protocols. (trunk r7023:7024) svn path=/main/branches/2.1.2/; revision=7026 --- diff --git a/pym/getbinpkg.py b/pym/getbinpkg.py index 8bd43f29c..9484d1d16 100644 --- a/pym/getbinpkg.py +++ b/pym/getbinpkg.py @@ -419,7 +419,24 @@ def file_get_lib(baseurl,dest,conn=None): elif protocol in ["ftp"]: data,rc,msg = make_ftp_request(conn, address, dest=dest) elif protocol == "sftp": - conn.get(address, dest) + rc = 0 + try: + f = conn.open(address) + except SystemExit: + raise + except Exception: + rc = 1 + else: + try: + if dest: + bufsize = 8192 + while True: + data = f.read(bufsize) + if not data: + break + dest.write(data) + finally: + f.close() else: raise TypeError, "Unknown protocol. '%s'" % protocol