aboutsummaryrefslogtreecommitdiffstats
path: root/global-functions
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2019-12-05 11:43:46 +0100
committerGravatar Christian Hesse <mail@eworm.de>2019-12-05 13:20:26 +0100
commit64341690bfbe01e6efc697746e6e34c1f0d5a3da (patch)
treea1d073a6aeaa30c9cc79164096a9b17f517bbbd5 /global-functions
parent7365bfa52510daba4cea452dcf786edaaf990a77 (diff)
global-functions: $DownloadPackage: retry on error
Diffstat (limited to 'global-functions')
-rw-r--r--global-functions29
1 files changed, 17 insertions, 12 deletions
diff --git a/global-functions b/global-functions
index 2bff9cc..d0d91a9 100644
--- a/global-functions
+++ b/global-functions
@@ -215,22 +215,27 @@
:local PkgDest [ $CleanFilePath ($PkgDir . "/" . $PkgFile) ];
$CertificateAvailable "Let's Encrypt Authority X3";
- :do {
- / tool fetch check-certificate=yes-without-crl \
- ("https://upgrade.mikrotik.com/routeros/" . $PkgVer . "/" . $PkgFile) \
- dst-path=$PkgDest;
- $WaitForFile $PkgDest;
- } on-error={
- / file remove [ find where name=$PkgDest ];
- :return false;
- }
- :if ([ / file get [ find where name=$PkgDest ] type ] != "package") do={
+ :local Retry 3;
+ :while ($Retry > 0) do={
+ :do {
+ / tool fetch check-certificate=yes-without-crl \
+ ("https://upgrade.mikrotik.com/routeros/" . $PkgVer . "/" . $PkgFile) \
+ dst-path=$PkgDest;
+ $WaitForFile $PkgDest;
+
+ :if ([ / file get [ find where name=$PkgDest ] type ] = "package") do={
+ :return true;
+ }
+ } on-error={
+ # catch error and fall through
+ }
+
/ file remove [ find where name=$PkgDest ];
- :return false;
+ :set Retry ($Retry - 1);
}
- :return true;
+ :return false;
}
# lock script against multiple invocation