correctly close file when we cancel a transfer. Fixes #7281
This commit is contained in:
parent
980492e33b
commit
19864ec80e
|
@ -790,6 +790,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
|
||||||
rep = nbxmpp.Protocol('iq', stanza.getFrom(), 'result',
|
rep = nbxmpp.Protocol('iq', stanza.getFrom(), 'result',
|
||||||
stanza.getTo(), {'id': stanza.getID()})
|
stanza.getTo(), {'id': stanza.getID()})
|
||||||
file_props.block_size = blocksize
|
file_props.block_size = blocksize
|
||||||
|
file_props.direction = '<'
|
||||||
file_props.seq = 0
|
file_props.seq = 0
|
||||||
file_props.received_len = 0
|
file_props.received_len = 0
|
||||||
file_props.last_time = time.time()
|
file_props.last_time = time.time()
|
||||||
|
@ -820,7 +821,6 @@ class ConnectionIBBytestream(ConnectionBytestream):
|
||||||
if session.weinitiate:
|
if session.weinitiate:
|
||||||
session.cancel_session()
|
session.cancel_session()
|
||||||
|
|
||||||
|
|
||||||
def OpenStream(self, sid, to, fp, blocksize=4096):
|
def OpenStream(self, sid, to, fp, blocksize=4096):
|
||||||
"""
|
"""
|
||||||
Start new stream. You should provide stream id 'sid', the endpoind jid
|
Start new stream. You should provide stream id 'sid', the endpoind jid
|
||||||
|
@ -997,7 +997,10 @@ class ConnectionIBBytestream(ConnectionBytestream):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if stanza.getTag('data'):
|
if stanza.getTag('data'):
|
||||||
if self.IBBMessageHandler(conn, stanza):
|
sid = stanza.getTagAttr('data', 'sid')
|
||||||
|
file_props = FilesProp.getFileProp(self.name, sid)
|
||||||
|
if file_props.connected and self.IBBMessageHandler(conn,
|
||||||
|
stanza):
|
||||||
reply = stanza.buildReply('result')
|
reply = stanza.buildReply('result')
|
||||||
reply.delChild('data')
|
reply.delChild('data')
|
||||||
conn.send(reply)
|
conn.send(reply)
|
||||||
|
|
|
@ -538,6 +538,7 @@ class Socks5:
|
||||||
raise IOError, e
|
raise IOError, e
|
||||||
|
|
||||||
def close_file(self):
|
def close_file(self):
|
||||||
|
# Close file we're sending from
|
||||||
if self.file:
|
if self.file:
|
||||||
if not self.file.closed:
|
if not self.file.closed:
|
||||||
try:
|
try:
|
||||||
|
@ -545,6 +546,12 @@ class Socks5:
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
self.file = None
|
self.file = None
|
||||||
|
# Close file we're receiving into
|
||||||
|
if self.file_props.fd:
|
||||||
|
try:
|
||||||
|
self.file_props.fd.close()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
def get_fd(self):
|
def get_fd(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue