From b423e6ed0f382ecdfd24e0b7b6d8e3dc4b43fede Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 9 Dec 2021 22:28:06 +0100 Subject: global-functions: $ScriptLock: cleanup in dedicated function --- global-functions | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'global-functions') diff --git a/global-functions b/global-functions index f5682be..ce538f3 100644 --- a/global-functions +++ b/global-functions @@ -945,18 +945,26 @@ :global ScriptLockOrder; - :local Count 0; :foreach Id,Ticket in=($ScriptLockOrder->$Script) do={ :if (($ScriptLockOrder->$Script->$Id) = $Remove) do={ :set ($ScriptLockOrder->$Script->$Id); } + } + } - :if ([ :typeof ($ScriptLockOrder->$Script->$Id) ] != "nothing") do={ - :set Count ($Count + 1); + :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 ($Count = 0) do={ + :if ($Clean = true) do={ :set ($ScriptLockOrder->$Script) [ :toarray "" ]; } } @@ -986,6 +994,7 @@ :if ([ $IsFirstTicket $Script $MyTicket ] = true && [ $TicketCount $Script ] = [ $JobCount $Script ]) do={ $RemoveTicket $Script $MyTicket; + $CleanupTickets $Script; :return false; } -- cgit v1.2.3-70-g09d2