From 44f7417b7f0e975a67b9159bf378ed356ff66856 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Sun, 22 Jun 2025 00:15:17 +0200 Subject: [PATCH] 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. --- global-functions.rsc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/global-functions.rsc b/global-functions.rsc index fd89f0f..829cbf2 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -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 ];