[project @ Arch-1:robey@lag.net--2003-public%secsh--dev--1.0--patch-118]
fix SFTPFile gettimeout/settimeout i don't think the gettimeout/settimeout calls on SFTPFile ever worked. also, simplify the implementation of _get_size() since it's nearly identical to stat().
This commit is contained in:
parent
0fa97ec147
commit
ad87909720
|
@ -73,7 +73,7 @@ class SFTPFile (BufferedFile):
|
||||||
before raising C{socket.timeout}, or C{None} for no timeout
|
before raising C{socket.timeout}, or C{None} for no timeout
|
||||||
@type timeout: float
|
@type timeout: float
|
||||||
"""
|
"""
|
||||||
self.sock.settimeout(timeout)
|
self.sftp.sock.settimeout(timeout)
|
||||||
|
|
||||||
def gettimeout(self):
|
def gettimeout(self):
|
||||||
"""
|
"""
|
||||||
|
@ -83,7 +83,7 @@ class SFTPFile (BufferedFile):
|
||||||
@see: L{Channel.gettimeout}
|
@see: L{Channel.gettimeout}
|
||||||
@rtype: float
|
@rtype: float
|
||||||
"""
|
"""
|
||||||
return self.sock.gettimeout()
|
return self.sftp.sock.gettimeout()
|
||||||
|
|
||||||
def setblocking(self, blocking):
|
def setblocking(self, blocking):
|
||||||
"""
|
"""
|
||||||
|
@ -95,7 +95,7 @@ class SFTPFile (BufferedFile):
|
||||||
mode.
|
mode.
|
||||||
@type blocking: int
|
@type blocking: int
|
||||||
"""
|
"""
|
||||||
self.sock.setblocking(blocking)
|
self.sftp.sock.setblocking(blocking)
|
||||||
|
|
||||||
def seek(self, offset, whence=0):
|
def seek(self, offset, whence=0):
|
||||||
self.flush()
|
self.flush()
|
||||||
|
@ -127,11 +127,7 @@ class SFTPFile (BufferedFile):
|
||||||
|
|
||||||
|
|
||||||
def _get_size(self):
|
def _get_size(self):
|
||||||
t, msg = self.sftp._request(CMD_FSTAT, self.handle)
|
|
||||||
if t != CMD_ATTRS:
|
|
||||||
raise SFTPError('Expected attrs')
|
|
||||||
attr = SFTPAttributes._from_msg(msg)
|
|
||||||
try:
|
try:
|
||||||
return attr.st_size
|
return self.stat().st_size
|
||||||
except:
|
except:
|
||||||
return 0
|
return 0
|
||||||
|
|
Loading…
Reference in New Issue