global-functions: add error handling

This commit is contained in:
Christian Hesse 2021-01-20 14:23:57 +01:00
parent 11d43e9fe5
commit c980699dd7

View file

@ -485,15 +485,23 @@
:set Dir [ $CleanFilePath $Dir ]; :set Dir [ $CleanFilePath $Dir ];
:if ([ :len [ / file find where name=$Dir type="directory" ] ] = 0) do={ :if ([ :len [ / file find where name=$Dir type="directory" ] ] = 1) do={
:local WwwVal [ / ip service get www ]; :return true;
/ ip service set www address=127.0.0.1/32 disabled=no port=80; }
:local Return true;
:local WwwVal [ / ip service get www ];
/ ip service set www address=127.0.0.1/32 disabled=no port=80;
:do {
/ tool fetch http://127.0.0.1/ dst-path=($Dir . "/tmp"); / tool fetch http://127.0.0.1/ dst-path=($Dir . "/tmp");
$WaitForFile ($Dir . "/tmp"); $WaitForFile ($Dir . "/tmp");
/ file remove ($Dir . "/tmp"); / file remove ($Dir . "/tmp");
/ ip service set www address=($WwwVal->"address") \ } on-error={
disabled=($WwwVal->"disabled") port=($WwwVal->"port"); :set Return false;
} }
/ ip service set www address=($WwwVal->"address") \
disabled=($WwwVal->"disabled") port=($WwwVal->"port");
:return $Return;
} }
# parse key value store # parse key value store