]> Git [git.vados.ru] :: Repos - Mikrotiks/ros.vados.ru.git/commitdiff
Autocommit in repo: ros.vados.ru, generated by owner: root, in 11:10:03 04.05.2026.
authorvados-dev <192440777+vados-dev@users.noreply.github.com>
Mon, 4 May 2026 08:10:03 +0000 (11:10 +0300)
committervados-dev <192440777+vados-dev@users.noreply.github.com>
Mon, 4 May 2026 08:10:03 +0000 (11:10 +0300)
html/AM-GlobalFunc.rsc

index 6dcf43e006b654795d6085a543537197fa94703b..d72e4c1f0b068e358747fdae98b1b38e040d2ce1 100644 (file)
@@ -17,9 +17,9 @@
 :global GlobalFuncReady false;
 
 # Git commit id & info, expected configuration version
-:global CommitId "main/545/3a63a0b7";
+:global CommitId "main/546/6df1efd6";
 :global CommitTAG "unknown";
-:global CommitInfo "Autocommit in repo: ros.vados.ru, generated by owner: root, in 11:00:03 04.05.2026.";
+:global CommitInfo "Autocommit in repo: ros.vados.ru, generated by owner: root, in 11:10:03 04.05.2026.";
 
 # The variables are received right here.
 :global GlobalConfVersion 140;
   :local CheckCert [:tostr $3];
   :local fetchMode [:tostr $4];
   :local fetchMethod [:tostr $5];
-  :local FetchString "undefined";
- 
   :global CleanName;
   :global FetchUserAgentStr;
   :global GetRandom20CharAlNum;
   :global WaitForFile;
 
   :set CheckCert [ $IfThenElse ($CheckCert = "false") "no" "yes-without-crl" ];
-  #:set fetchMode [ $IfThenElse ($fetchMode != "false") [:tostr ("mode=" . $fetchMode)] ];
-  #:set fetchMethod [$IfThenElse ($fetchMethod != "false") [:tostr ("http-method=\"" . $fetchMethod . "\"") ]];
-  
   :local DirName ("tmpfs/" . [ $CleanName $FetchLargeScript ]);
   :if ([ $MkDir $DirName ] = false) do={
     :log error ($FetchLargeScript . " Failed creating directory!");
     :return false;
   }
   :local FileName ($DirName . "/" . [ $CleanName $fetchUrl ] . "-" . [ $GetRandom20CharAlNum ]);
-  #/tool/fetch check-certificate=$CheckCert $Url dst-path=$FileName http-header-field=({ [ $FetchUserAgentStr $FetchLargeScript ] }) as-value;
-  #:log warning ("\$fUrl =" . $2 . ({[ $fMode ]}));
-    :onerror Err {
-      :set FetchString ("/tool/fetch " . \
-      [$IfThenElse ([$fetchMethod] != "false") ("http-method=\"" . $fetchMethod . "\" ")] . \
-      "check-certificate=" . $CheckCert . " url=(\"" . $fetchUrl . "\") " . \
-      [$IfThenElse ([$fetchMode] != "false") ("mode=" . $fetchMode . " ")] . \
-      http-header-field=({ [ $FetchUserAgentStr $FetchLargeScript ] }) as-value);
-      :log warning ("\$FetchSring = " . $FetchString);
-      :put [$FetchString];
-    #:put [/tool/fetch $fetchMode check-certificate=$CheckCert url=($fetchUrl) dst-path=($FileName) http-header-field=({ [ $FetchUserAgentStr $FetchLargeScript ] }) as-value];
-  } do={
-    :if ([ $WaitForFile $FileName 500ms ] = true) do={
-      $RmFile $FileName;
+  
+  :do {
+    :if ($fetchMethod = "false") do={
+      :if ($fetchMode = "false") do={
+        /tool/fetch url=($fetchUrl) dst-path=$FileName check-certificate=$CheckCert http-header-field=({ [ $FetchUserAgentStr $FetchLargeScript ] }) as-value;
+      } else={
+        /tool/fetch url=($fetchUrl) dst-path=$FileName check-certificate=$CheckCert http-header-field=({ [ $FetchUserAgentStr $FetchLargeScript ] }) mode=$fetchMode as-value;
+      }
+    } else={
+      :if ($fetchMode = "false") do={
+        /tool/fetch url=($fetchUrl) dst-path=$FileName check-certificate=$CheckCert http-header-field=({ [ $FetchUserAgentStr $FetchLargeScript ] }) http-method=$fetchMethod as-value;
+      } else={
+        /tool/fetch url=($fetchUrl) dst-path=$FileName check-certificate=$CheckCert http-header-field=({ [ $FetchUserAgentStr $FetchLargeScript ] }) http-method=$fetchMethod mode=$fetchMode as-value;
+      }
     }
-    $LogPrint debug $0 ("Failed downloading from " . $fetchUrl . " - " . $Err);
+  } on-error={
+    $LogPrint error $0 ("Failed downloading from " . $fetchUrl . " - " . $Err);
     $RmDir $DirName;
     :return false;
   }
+
   :if ([ $WaitForFile $FileName 5s ] = false) do={
-    $LogPrint debug $0 ("The file downloaded from " . $fetchUrl . " did not show up.");
+    $LogPrint error $0 ("The file downloaded from " . $fetchUrl . " did not show up.");
+    $RmDir $DirName;
     :return false;
   }
+
   :local FileSize [ /file/get $FileName size ];
   :local Return "";
   :local VarSize 0;
       :delay 100ms;
     }
   }
+  $RmFile $FileName;
   $RmDir $DirName;
   :return $Return;
 }
 
 # signal we are ready
 :set GlobalFuncReady true;
-
-:do {
-:onerror Err {
-  :global GlobalConfReady;
-  :retry { :if ($GlobalConfReady != true) \
-    do={ :error ("Global config not ready."); }; } delay=500ms max=50;
-  } do={
-  :global ExitOnError; $ExitOnError $0 $Err;
-  }
-}