diff mbox series

[1/2] support/download: catch post-process errors

Message ID 20230210223143.1060114-1-yann.morin.1998@free.fr
State Accepted
Headers show
Series [1/2] support/download: catch post-process errors | expand

Commit Message

Yann E. MORIN Feb. 10, 2023, 10:31 p.m. UTC
Currently, when the post-process helper fails while downloading from
upstream, there is no fallback to the backup mirror.

In case the post-process helper fails, we mut consider that to be a
download failure, so we must bail out as if the download backend itself
did fail, but we fail to do so.

Duplicate the logic we have for the download helper: if the post-process
helper fails, remove the downloaded stuff, and continue on to the next
URI, which will ultimately hit the backup mirror (if one has been
configured).

Reported-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 support/download/dl-wrapper | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Peter Korsgaard Feb. 12, 2023, 8:39 a.m. UTC | #1
>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:

 > Currently, when the post-process helper fails while downloading from
 > upstream, there is no fallback to the backup mirror.

 > In case the post-process helper fails, we mut consider that to be a
 > download failure, so we must bail out as if the download backend itself
 > did fail, but we fail to do so.

 > Duplicate the logic we have for the download helper: if the post-process
 > helper fails, remove the downloaded stuff, and continue on to the next
 > URI, which will ultimately hit the backup mirror (if one has been
 > configured).

 > Reported-by: Peter Korsgaard <peter@korsgaard.com>
 > Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
 > Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>

Committed after adding a fixes:
http://autobuild.buildroot.net/results/12a/12a63ae177fe3ed0c9a1ef2fa01870f334f36b0f/,
thanks!

> ---
 >  support/download/dl-wrapper | 12 +++++++++---
 >  1 file changed, 9 insertions(+), 3 deletions(-)

 > diff --git a/support/download/dl-wrapper b/support/download/dl-wrapper
 > index 09a6ac1f1a..1e8d6058f6 100755
 > --- a/support/download/dl-wrapper
 > +++ b/support/download/dl-wrapper
 > @@ -138,9 +138,15 @@ main() {
 >          fi
 
 >          if [ -n "${post_process}" ] ; then
 > -            "${OLDPWD}/support/download/${post_process}-post-process" \
 > -                -o "${tmpf}" \
 > -                -n "${raw_base_name}"
 > +            if ! "${OLDPWD}/support/download/${post_process}-post-process" \
 > +                    -o "${tmpf}" \
 > +                    -n "${raw_base_name}"
 > +            then
 > +                # cd back to keep path coherence
 > +                cd "${OLDPWD}"
 > +                rm -rf "${tmpd}"
 > +                continue
 > +            fi
 >          fi
 
 >          # cd back to free the temp-dir, so we can remove it later
 > -- 

 > 2.25.1
Peter Korsgaard Feb. 28, 2023, 9:13 p.m. UTC | #2
>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:

 > Currently, when the post-process helper fails while downloading from
 > upstream, there is no fallback to the backup mirror.

 > In case the post-process helper fails, we mut consider that to be a
 > download failure, so we must bail out as if the download backend itself
 > did fail, but we fail to do so.

 > Duplicate the logic we have for the download helper: if the post-process
 > helper fails, remove the downloaded stuff, and continue on to the next
 > URI, which will ultimately hit the backup mirror (if one has been
 > configured).

 > Reported-by: Peter Korsgaard <peter@korsgaard.com>
 > Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
 > Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>

Committed to 2022.11.x and 2022.02.x, thanks.
diff mbox series

Patch

diff --git a/support/download/dl-wrapper b/support/download/dl-wrapper
index 09a6ac1f1a..1e8d6058f6 100755
--- a/support/download/dl-wrapper
+++ b/support/download/dl-wrapper
@@ -138,9 +138,15 @@  main() {
         fi
 
         if [ -n "${post_process}" ] ; then
-            "${OLDPWD}/support/download/${post_process}-post-process" \
-                -o "${tmpf}" \
-                -n "${raw_base_name}"
+            if ! "${OLDPWD}/support/download/${post_process}-post-process" \
+                    -o "${tmpf}" \
+                    -n "${raw_base_name}"
+            then
+                # cd back to keep path coherence
+                cd "${OLDPWD}"
+                rm -rf "${tmpd}"
+                continue
+            fi
         fi
 
         # cd back to free the temp-dir, so we can remove it later