mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
global-functions: $FetchHuge: remove temporary directory
This commit is contained in:
parent
57ebcfb41c
commit
4006d07222
1 changed files with 5 additions and 4 deletions
|
@ -406,13 +406,13 @@
|
|||
|
||||
:set CheckCert [ $IfThenElse ($CheckCert = false) "no" "yes-without-crl" ];
|
||||
|
||||
:local FileName ("tmpfs/" . [ $CleanName $ScriptName ]);
|
||||
:if ([ $MkDir $FileName ] = false) do={
|
||||
:local DirName ("tmpfs/" . [ $CleanName $ScriptName ]);
|
||||
:if ([ $MkDir $DirName ] = false) do={
|
||||
$LogPrint error $0 ("Failed creating directory!");
|
||||
:return false;
|
||||
}
|
||||
|
||||
:set FileName ($FileName . "/" . [ $CleanName $0 ] . "-" . [ $GetRandom20CharAlNum ]);
|
||||
:local FileName ($DirName . "/" . [ $CleanName $0 ] . "-" . [ $GetRandom20CharAlNum ]);
|
||||
:do {
|
||||
/tool/fetch check-certificate=$CheckCert $Url dst-path=$FileName \
|
||||
http-header-field=({ [ $FetchUserAgentStr $ScriptName ] }) as-value;
|
||||
|
@ -421,6 +421,7 @@
|
|||
/file/remove $FileName;
|
||||
}
|
||||
$LogPrint debug $0 ("Failed downloading from: " . $Url);
|
||||
/file/remove $DirName;
|
||||
:return false;
|
||||
}
|
||||
$WaitForFile $FileName;
|
||||
|
@ -432,7 +433,7 @@
|
|||
:set Return ($Return . ([ /file/read offset=$VarSize chunk-size=32768 file=$FileName as-value ]->"data"));
|
||||
:set VarSize [ :len $Return ];
|
||||
}
|
||||
/file/remove $FileName;
|
||||
/file/remove $DirName;
|
||||
:return $Return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue