global-functions: add $WaitForFile, wait for file on fetch

The fetch command is asynchronous, the file is not guaranteed to be
available when command terminates.

I opened an issue at Mikrotik support (Ticket#2019041722004999),
their answer:

> You should perform a check in a loop.
> :delay until file exist
>
> That can happen also with any configuration not just files.

So add a function to wait for a file with given name.

I have not seen this with other configuration, though.
This commit is contained in:
Christian Hesse 2019-04-18 10:39:32 +02:00
parent 9aac873163
commit 7f96e5c966
5 changed files with 35 additions and 4 deletions

View file

@ -10,9 +10,10 @@
:global Identity;
:global DailyPskMatchComment;
:global UrlEncode;
:global SendNotification;
:global UrlEncode;
:global WaitForFile;
:local Seen [ :toarray "" ];
@ -82,6 +83,7 @@
:do {
/ tool fetch check-certificate=yes-without-crl \
$Url dst-path=$Attach;
$WaitForFile $Attach;
} on-error={
:set Attach "";
}