aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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