better file transfer error handling. Fixes #5064

This commit is contained in:
Yann Leboulanger 2009-07-28 23:13:34 +02:00
parent 492abfb407
commit 1c7b265c9c
4 changed files with 24 additions and 7 deletions

View File

@ -489,7 +489,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()
@ -505,7 +510,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:

View File

@ -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):

View File

@ -1768,7 +1768,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 = ''
@ -1777,7 +1780,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')

View File

@ -1838,7 +1838,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':