# HG changeset patch
# User Goffi <goffi@goffi.org>
# Date 1620317493 -7200
# Node ID 1658472abd7722bc8d4d602aea9ca68535a107be
# Parent  4b33ed5abd8fe1934497055604bf4dc80cca02ae
plugin upload: don't run `available_cb` if `upload_jid` is used in `upload` method

diff -r 4b33ed5abd8f -r 1658472abd77 sat/plugins/plugin_misc_upload.py
--- 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)