diff options
-rw-r--r-- | global-functions | 11 | ||||
-rw-r--r-- | telegram-chat | 2 |
2 files changed, 7 insertions, 6 deletions
diff --git a/global-functions b/global-functions index 2f57fae..d2f911e 100644 --- a/global-functions +++ b/global-functions @@ -1213,20 +1213,21 @@ # wait for file to be available :set WaitForFile do={ - :local FileName [ :tostr $1 ]; - :local Iter [ :tonum $2 ]; + :local FileName [ :tostr $1 ]; + :local WaitTime [ :totime $2 ]; :global CleanFilePath; :global EitherOr; :set FileName [ $CleanFilePath $FileName ]; - :local I 0; + :local I 1; + :local Delay ([ :totime [ $EitherOr $WaitTime 2s ] ] / 20); :while ([ :len [ /file/find where name=$FileName ] ] = 0) do={ - :if ($I > [ $EitherOr $Iter 20 ]) do={ + :if ($I >= 20) do={ :return false; } - :delay 100ms; + :delay $Delay; :set I ($I + 1); } :return true; diff --git a/telegram-chat b/telegram-chat index 93d4294..2d3cee6 100644 --- a/telegram-chat +++ b/telegram-chat @@ -103,7 +103,7 @@ $WaitFullyConnected; $LogPrintExit2 info $0 ("Running command: " . $Text) false; :exec script=(":do {\n" . $Text . "\n} on-error={ :execute script=\":put\" file=" . $File . ".failed };" . \ ":execute script=\":put\" file=" . $File . ".done") file=$File; - :if ([ $WaitForFile ($File . ".done.txt") 200 ] = false) do={ + :if ([ $WaitForFile ($File . ".done.txt") 20s ] = false) do={ :set State "The command did not finish, still running in background.\n\n"; } :if ([ :len [ /file/find where name=($File . ".failed.txt") ] ] > 0) do={ |