comparison sat/plugins/plugin_misc_upload.py @ 3534:1658472abd77

plugin upload: don't run `available_cb` if `upload_jid` is used in `upload` method
author Goffi <goffi@goffi.org>
date Thu, 06 May 2021 18:11:33 +0200
parents be6d91572633
children 0ff265725489
comparison
equal deleted inserted replaced
3533:4b33ed5abd8f 3534:1658472abd77
78 78
79 parameters are the same as for [upload] 79 parameters are the same as for [upload]
80 @return (dict): action dictionary, with progress id in case of success, else xmlui 80 @return (dict): action dictionary, with progress id in case of success, else xmlui
81 message 81 message
82 """ 82 """
83
84 try: 83 try:
85 progress_id, __ = await self.upload( 84 progress_id, __ = await self.upload(
86 client, filepath, filename, upload_jid, options) 85 client, filepath, filename, upload_jid, options)
87 except Exception as e: 86 except Exception as e:
88 if (isinstance(e, jabber_error.StanzaError) 87 if (isinstance(e, jabber_error.StanzaError)
121 if options is None: 120 if options is None:
122 options = {} 121 options = {}
123 if not os.path.isfile(filepath): 122 if not os.path.isfile(filepath):
124 raise exceptions.DataError("The given path doesn't link to a file") 123 raise exceptions.DataError("The given path doesn't link to a file")
125 for method_name, available_cb, upload_cb, priority in self._upload_callbacks: 124 for method_name, available_cb, upload_cb, priority in self._upload_callbacks:
126 try: 125 if upload_jid is None:
127 upload_jid = await available_cb(client, upload_jid) 126 try:
128 except exceptions.NotFound: 127 upload_jid = await available_cb(client, upload_jid)
129 continue # no entity managing this extension found 128 except exceptions.NotFound:
129 continue # no entity managing this extension found
130 130
131 log.info( 131 log.info(
132 "{name} method will be used to upload the file".format(name=method_name) 132 "{name} method will be used to upload the file".format(name=method_name)
133 ) 133 )
134 progress_id, download_d = await upload_cb( 134 progress_id, download_d = await upload_cb(