global-functions: detect failed package downloads

This commit is contained in:
Christian Hesse 2019-02-14 20:35:13 +01:00
parent 151435ba0c
commit f127e3b7ef

View file

@ -178,9 +178,17 @@
/ tool fetch mode=https check-certificate=yes-without-crl \ / tool fetch mode=https check-certificate=yes-without-crl \
("https://upgrade.mikrotik.com/routeros/" . $PkgVer . "/" . $PkgFile) \ ("https://upgrade.mikrotik.com/routeros/" . $PkgVer . "/" . $PkgFile) \
dst-path=$PkgDest; dst-path=$PkgDest;
:return true;
} on-error={ } on-error={
/ file remove [ find where name=$PkgDest ]; / file remove [ find where name=$PkgDest ];
:return false; :return false;
} }
# Fetch tool in RouterOS has an issue where it truncates files on slow
# storage. Detect that... TODO: Remove when fixed. (Ticket#2019021122006199)
:if ([ / file get [ find where name=$PkgDest ] type ] != "package") do={
/ file remove [ find where name=$PkgDest ];
:return false;
}
:return true;
} }