Commit 1a8b94aa authored by Yann Leboulanger's avatar Yann Leboulanger

better file transfer error handling. Fixes #5064

parent 4dbd848f
......@@ -488,7 +488,12 @@ class Socks5:
return None
fd = None
if self.remaining_buff != '':
fd = self.get_fd()
try:
fd = self.get_fd()
except IOError, e:
self.disconnect(False)
self.file_props['error'] = -6 # file system error
return 0
fd.write(self.remaining_buff)
lenn = len(self.remaining_buff)
current_time = self.idlequeue.current_time()
......@@ -504,7 +509,12 @@ class Socks5:
self.file_props['completed'] = True
return 0
else:
fd = self.get_fd()
try:
fd = self.get_fd()
except IOError, e:
self.disconnect(False)
self.file_props['error'] = -6 # file system error
return 0
try:
buff = self._recv(MAX_BUFF_LEN)
except Exception, e:
......
......@@ -228,8 +228,7 @@ _('Connection with peer cannot be established.'))
sectext += '\n\t' + _('Recipient: %s') % jid
if error_msg:
sectext += '\n\t' + _('Error message: %s') % error_msg
dialogs.ErrorDialog(_('File transfer stopped by the contact at the other '
'end'), sectext)
dialogs.ErrorDialog(_('File transfer stopped'), sectext)
self.tree.get_selection().unselect_all()
def show_file_send_request(self, account, contact):
......
......@@ -1800,7 +1800,10 @@ class Interface:
if gajim.config.get('notify_on_file_complete'):
ft.show_completed(jid, file_props)
elif file_props['error'] == -1:
ft.show_stopped(jid, file_props)
ft.show_stopped(jid, file_props,
error_msg=_('Remote contact stopped transfer'))
elif file_props['error'] == -6:
ft.show_stopped(jid, file_props, error_msg=_('Error opening file'))
return
msg_type = ''
......@@ -1809,7 +1812,7 @@ class Interface:
'notify_on_file_complete'):
msg_type = 'file-completed'
event_type = _('File Transfer Completed')
elif file_props['error'] == -1:
elif file_props['error'] in (-1, -6):
msg_type = 'file-stopped'
event_type = _('File Transfer Stopped')
......
......@@ -1816,7 +1816,12 @@ class RosterWindow:
gajim.events.remove_events(account, jid, event)
return True
elif event.type_ in ('file-error', 'file-stopped'):
ft.show_stopped(jid, data)
msg_error = ''
if data['error'] == -1:
msg_err = _('Remote contact stopped transfer')
elif data['error'] == -6:
msg_err = _('Error opening file')
ft.show_stopped(jid, data, error_msg=msg_err)
gajim.events.remove_events(account, jid, event)
return True
elif event.type_ == 'file-completed':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment