changeset 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 (2021-05-06)
parents 4b33ed5abd8f
children 67aebefb44fc
files sat/plugins/plugin_misc_upload.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/sat/plugins/plugin_misc_upload.py	Thu May 06 18:10:09 2021 +0200
+++ b/sat/plugins/plugin_misc_upload.py	Thu May 06 18:11:33 2021 +0200
@@ -80,7 +80,6 @@
         @return (dict): action dictionary, with progress id in case of success, else xmlui
             message
         """
-
         try:
             progress_id, __ = await self.upload(
                 client, filepath, filename, upload_jid, options)
@@ -123,10 +122,11 @@
         if not os.path.isfile(filepath):
             raise exceptions.DataError("The given path doesn't link to a file")
         for method_name, available_cb, upload_cb, priority in self._upload_callbacks:
-            try:
-                upload_jid = await available_cb(client, upload_jid)
-            except exceptions.NotFound:
-                continue  # no entity managing this extension found
+            if upload_jid is None:
+                try:
+                    upload_jid = await available_cb(client, upload_jid)
+                except exceptions.NotFound:
+                    continue  # no entity managing this extension found
 
             log.info(
                 "{name} method will be used to upload the file".format(name=method_name)