global-functions: $RmFile: fix type safeguard

Ups... 🫣
The type is not just literal 'file' - but what ever type the file is,
like 'backup', 'package', 'script', '.conf file', ...

So let's match those types we do *not* want to remove.

Fixes: https://github.com/eworm-de/routeros-scripts/issues/90
This commit is contained in:
Christian Hesse 2025-02-13 17:49:42 +01:00
parent 0199ea8884
commit dafcc1a0cb

View file

@ -1054,12 +1054,12 @@
$LogPrint debug $0 ("Removing file: ". $FileName);
:if ([ :len [ /file/find where name=$FileName type!=file ] ] > 0) do={
:if ([ :len [ /file/find where name=$FileName (type=directory or type=disk) ] ] > 0) do={
$LogPrint error $0 ("File '" . $FileName . "' is not a file.");
:return false;
}
:local File [ /file/find where name=$FileName type=file ];
:local File [ /file/find where name=$FileName !(type=directory or type=disk) ];
:if ([ :len $File ] = 0) do={
$LogPrint debug $0 ("... which does not exist.");
:return true;