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 return None
fd = None fd = None
if self.remaining_buff != '': 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) fd.write(self.remaining_buff)
lenn = len(self.remaining_buff) lenn = len(self.remaining_buff)
current_time = self.idlequeue.current_time() current_time = self.idlequeue.current_time()
@ -505,7 +510,12 @@ class Socks5:
self.file_props['completed'] = True self.file_props['completed'] = True
return 0 return 0
else: 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: try:
buff = self._recv(MAX_BUFF_LEN) buff = self._recv(MAX_BUFF_LEN)
except Exception: except Exception:

View File

@ -228,8 +228,7 @@ _('Connection with peer cannot be established.'))
sectext += '\n\t' + _('Recipient: %s') % jid sectext += '\n\t' + _('Recipient: %s') % jid
if error_msg: if error_msg:
sectext += '\n\t' + _('Error message: %s') % error_msg sectext += '\n\t' + _('Error message: %s') % error_msg
dialogs.ErrorDialog(_('File transfer stopped by the contact at the other ' dialogs.ErrorDialog(_('File transfer stopped'), sectext)
'end'), sectext)
self.tree.get_selection().unselect_all() self.tree.get_selection().unselect_all()
def show_file_send_request(self, account, contact): def show_file_send_request(self, account, contact):

View File

@ -1768,7 +1768,10 @@ class Interface:
if gajim.config.get('notify_on_file_complete'): if gajim.config.get('notify_on_file_complete'):
ft.show_completed(jid, file_props) ft.show_completed(jid, file_props)
elif file_props['error'] == -1: 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 return
msg_type = '' msg_type = ''
@ -1777,7 +1780,7 @@ class Interface:
'notify_on_file_complete'): 'notify_on_file_complete'):
msg_type = 'file-completed' msg_type = 'file-completed'
event_type = _('File Transfer Completed') event_type = _('File Transfer Completed')
elif file_props['error'] == -1: elif file_props['error'] in (-1, -6):
msg_type = 'file-stopped' msg_type = 'file-stopped'
event_type = _('File Transfer Stopped') event_type = _('File Transfer Stopped')

View File

@ -1838,7 +1838,12 @@ class RosterWindow:
gajim.events.remove_events(account, jid, event) gajim.events.remove_events(account, jid, event)
return True return True
elif event.type_ in ('file-error', 'file-stopped'): 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) gajim.events.remove_events(account, jid, event)
return True return True
elif event.type_ == 'file-completed': elif event.type_ == 'file-completed':