changeset 1cf7d602453e in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=1cf7d602453e description: correctly close the file when we cancel a transfer. Fixes #7281
diffstat:
src/common/jingle_session.py | 1 + src/common/protocol/bytestream.py | 19 ++++++++++++++----- src/common/socks5.py | 9 +++++++++ 3 files changed, 24 insertions(+), 5 deletions(-)
diffs (88 lines):
diff -r 2771bf0bedd8 -r 1cf7d602453e src/common/jingle_session.py --- a/src/common/jingle_session.py Fri Jan 11 23:00:14 2013 +0400 +++ b/src/common/jingle_session.py Thu Jan 24 20:26:18 2013 +0100 @@ -311,6 +311,7 @@ Default callback for action stanzas -- simple ack and stop processing """ response = stanza.buildReply('result') + response.delChild(response.getQuery()) self.connection.connection.send(response)
def __on_error(self, stanza, jingle, error, action): diff -r 2771bf0bedd8 -r 1cf7d602453e src/common/protocol/bytestream.py --- a/src/common/protocol/bytestream.py Fri Jan 11 23:00:14 2013 +0400 +++ b/src/common/protocol/bytestream.py Thu Jan 24 20:26:18 2013 +0100 @@ -314,9 +314,16 @@
if 'direction' in file_props: # it's a IBB - sid = file_props['sid'] - if sid in self.files_props: - del self.files_props[sid] + # Close file we're receiving into + if 'fp' in file_props: + fd = file_props['fp'] + try: + fd.close() + except Exception: + pass + if gajim.socks5queue.get_file_props(self.name, file_props['sid']): + gajim.socks5queue.remove_file_props(self.name, + file_props['sid'])
def _send_socks5_info(self, file_props): """ @@ -741,9 +748,9 @@ elif typ == 'set' and stanza.getTag('close', namespace=xmpp.NS_IBB): self.StreamCloseHandler(conn, stanza) elif typ == 'result': - self.StreamCommitHandler(conn, stanza) + self.SendHandler() elif typ == 'error': - self.StreamOpenReplyHandler(conn, stanza) + gajim.socks5queue.error_cb(_('File transfer canceled'), _('An error occured while transfering file.')) else: conn.send(xmpp.Error(stanza, xmpp.ERR_BAD_REQUEST)) raise xmpp.NodeProcessed @@ -773,6 +780,7 @@ rep = xmpp.Protocol('iq', stanza.getFrom(), 'result', stanza.getTo(), {'id': stanza.getID()}) file_props['block-size'] = blocksize + file_props['direction'] = '<' file_props['seq'] = 0 file_props['received-len'] = 0 file_props['last-time'] = time.time() @@ -964,6 +972,7 @@ if stanza.getTag('data'): if self.IBBMessageHandler(conn, stanza): reply = stanza.buildReply('result') + reply.delChild(reply.getQuery()) conn.send(reply) raise xmpp.NodeProcessed elif syn_id == self.last_sent_ibb_id: diff -r 2771bf0bedd8 -r 1cf7d602453e src/common/socks5.py --- a/src/common/socks5.py Fri Jan 11 23:00:14 2013 +0400 +++ b/src/common/socks5.py Thu Jan 24 20:26:18 2013 +0100 @@ -397,6 +397,7 @@ raise IOError, e
def close_file(self): + # Close file we're sending from if self.file: if not self.file.closed: try: @@ -404,6 +405,14 @@ except Exception: pass self.file = None + # Close file we're receiving into + if 'fd' in self.file_props: + fd = self.file_props['fd'] + del self.file_props['fd'] + try: + fd.close() + except Exception: + pass
def get_fd(self): """