global-functions: $FileGet: mitigate race with file properties

RouterOS is suffering a race condition, where a file exists, but its
properties are not (yet) available. This is handled in $WaitForFile.

This passes an interval of zero to $WaitForFile, as does not wait for
the file to exist, but wants to avoid the race only.
This commit is contained in:
Christian Hesse 2025-06-22 00:15:17 +02:00
parent b3dc8eb92a
commit 44f7417b7f

View file

@ -559,6 +559,12 @@
:set FileGet do={
:local FileName [ :tostr $1 ];
:global WaitForFile;
:if ([ $WaitForFile $FileName 0s ] = false) do={
:return false;
}
:local FileVal false;
:do {
:set FileVal [ /file/get $FileName ];