Philipp Hörist pushed to branch master at gajim / gajim

Commits:

1 changed file:

Changes:

  • gajim/common/modules/httpupload.py
    ... ... @@ -21,7 +21,8 @@ from urllib.parse import urlparse
    21 21
     import mimetypes
    
    22 22
     
    
    23 23
     from nbxmpp.namespaces import Namespace
    
    24
    -from nbxmpp.util import is_error_result
    
    24
    +from nbxmpp.errors import StanzaError
    
    25
    +from nbxmpp.errors import MalformedStanzaError
    
    25 26
     from nbxmpp.util import convert_tls_error_flags
    
    26 27
     from gi.repository import GLib
    
    27 28
     from gi.repository import Soup
    
    ... ... @@ -161,20 +162,24 @@ class HTTPUpload(BaseModule):
    161 162
                 callback=self._received_slot,
    
    162 163
                 user_data=transfer)
    
    163 164
     
    
    164
    -    def _received_slot(self, result, transfer):
    
    165
    -        if is_error_result(result):
    
    165
    +    def _received_slot(self, task):
    
    166
    +        transfer = task.get_user_data()
    
    167
    +
    
    168
    +        try:
    
    169
    +            result = task.finish()
    
    170
    +        except (StanzaError, MalformedStanzaError) as error:
    
    166 171
                 transfer.set_error()
    
    167 172
     
    
    168
    -            if result.app_condition == 'file-too-large':
    
    173
    +            if error.app_condition == 'file-too-large':
    
    169 174
                     size_text = GLib.format_size_full(
    
    170
    -                    result.get_max_file_size(),
    
    175
    +                    error.get_max_file_size(),
    
    171 176
                         GLib.FormatSizeFlags.IEC_UNITS)
    
    172 177
     
    
    173 178
                     error_text = _('File is too large, '
    
    174 179
                                    'maximum allowed file size is: %s' % size_text)
    
    175 180
                 else:
    
    176
    -                error_text = str(result)
    
    177
    -                self._log.warning(result)
    
    181
    +                error_text = str(error)
    
    182
    +                self._log.warning(error)
    
    178 183
     
    
    179 184
                 self._raise_information_event('request-upload-slot-error',
    
    180 185
                                               error_text)