mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
global-functions: $ScriptLock: cleanup in dedicated function
This commit is contained in:
parent
327740d255
commit
b423e6ed0f
1 changed files with 13 additions and 4 deletions
|
@ -945,18 +945,26 @@
|
||||||
|
|
||||||
:global ScriptLockOrder;
|
:global ScriptLockOrder;
|
||||||
|
|
||||||
:local Count 0;
|
|
||||||
:foreach Id,Ticket in=($ScriptLockOrder->$Script) do={
|
:foreach Id,Ticket in=($ScriptLockOrder->$Script) do={
|
||||||
:if (($ScriptLockOrder->$Script->$Id) = $Remove) do={
|
:if (($ScriptLockOrder->$Script->$Id) = $Remove) do={
|
||||||
:set ($ScriptLockOrder->$Script->$Id);
|
:set ($ScriptLockOrder->$Script->$Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ([ :typeof ($ScriptLockOrder->$Script->$Id) ] != "nothing") do={
|
|
||||||
:set Count ($Count + 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:if ($Count = 0) do={
|
:local CleanupTickets do={
|
||||||
|
:local Script [ :tostr $1 ];
|
||||||
|
|
||||||
|
:global ScriptLockOrder;
|
||||||
|
|
||||||
|
:local Clean true;
|
||||||
|
:foreach Ticket in=($ScriptLockOrder->$Script) do={
|
||||||
|
:if ([ :typeof $Ticket ] != "nothing") do={
|
||||||
|
:set Clean false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:if ($Clean = true) do={
|
||||||
:set ($ScriptLockOrder->$Script) [ :toarray "" ];
|
:set ($ScriptLockOrder->$Script) [ :toarray "" ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -986,6 +994,7 @@
|
||||||
|
|
||||||
:if ([ $IsFirstTicket $Script $MyTicket ] = true && [ $TicketCount $Script ] = [ $JobCount $Script ]) do={
|
:if ([ $IsFirstTicket $Script $MyTicket ] = true && [ $TicketCount $Script ] = [ $JobCount $Script ]) do={
|
||||||
$RemoveTicket $Script $MyTicket;
|
$RemoveTicket $Script $MyTicket;
|
||||||
|
$CleanupTickets $Script;
|
||||||
:return false;
|
:return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue