From d60950ba38c11d7e6d7d57a8ef5faf8ebc055134 Mon Sep 17 00:00:00 2001 From: Gilgamesh Athoraya Date: Tue, 12 Sep 2023 11:33:52 +0200 Subject: [PATCH 01/12] Create FSW with filters for relevant extensions --- StartupSession/Link/Watcher.apln | 39 +++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/StartupSession/Link/Watcher.apln b/StartupSession/Link/Watcher.apln index b020ab06..8444d058 100644 --- a/StartupSession/Link/Watcher.apln +++ b/StartupSession/Link/Watcher.apln @@ -109,31 +109,48 @@ :EndDisposable ∇ - ∇ watcher←MakeWatcher args;⎕USING - ⍝ Return a FileSystemWatcher object + ∇ r←MakeWatcher args;filter;filters;path;watcher;⎕USING + ⍝ Return FileSystemWatcher object(s) ⍝ Try .Net Core rather than Framework if non-Windows or DYALOG_NETCORE explicitly set + ⍝ Creates a vector of watchers on .Net Framework to watch specific extensions. + ⍝ dotnet supports collection of filters on single watcher. ⎕USING←',System',(~DOTNETCORE)/'.dll' - watcher←⎕NEW System.IO.FileSystemWatcher - watcher.(Path Filter)←args - watcher.(onChanged onCreated onDeleted onRenamed)←⊂'WatchEvent' - watcher.onError←'WatchError' - watcher.IncludeSubdirectories←1 + path filters←args + :If DOTNETCORE + watcher←⎕NEW System.IO.FileSystemWatcher + watcher.Path←path + watcher.Filters.Add¨⊂¨⊆filters + watcher.(onChanged onCreated onDeleted onRenamed)←⊂'WatchEvent' + watcher.onError←'WatchError' + watcher.IncludeSubdirectories←1 + r←watcher + :Else + r←⍬ + :For filter :In ⊆filters + watcher←⎕NEW System.IO.FileSystemWatcher + watcher.Path←path + watcher.Filter←filter + watcher.(onChanged onCreated onDeleted onRenamed)←⊂'WatchEvent' + watcher.onError←'WatchError' + watcher.IncludeSubdirectories←1 + r,←watcher + :EndFor + :EndIf ∇ - ⍝⍝⍝⍝⍝ MAIN API ⍝⍝⍝⍝⍝⍝⍝⍝ - ∇ Watch link;args;end;q;r;tid;z + ∇ Watch link;filters;end;q;r;tid;z ⍝ Set up a file system watcher, return object that will be stored as "fsw" in ⎕SE.Link.Links[i] link.fsw←⎕NULL :If ~'dir' 'both'∊⍨⊂link.watch :Return :EndIf :If DOTNET - args←link.dir(,'*') - r←MakeWatcher args + filters←(⊂'*.'),¨∪link.(codeExtensions,customExtensions,⊢/typeExtensions) + r←MakeWatcher link.dir filters r.EnableRaisingEvents←1 link.fsw←r :ElseIf CRAWLER From 52244fc2cd83a0f7a8cc773e75e4f161b5430323 Mon Sep 17 00:00:00 2001 From: Gilgamesh Athoraya Date: Tue, 12 Sep 2023 15:23:57 +0200 Subject: [PATCH 02/12] Add separate watcher for directory changes --- StartupSession/Link/Watcher.apln | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/StartupSession/Link/Watcher.apln b/StartupSession/Link/Watcher.apln index 8444d058..50fbbb86 100644 --- a/StartupSession/Link/Watcher.apln +++ b/StartupSession/Link/Watcher.apln @@ -116,26 +116,27 @@ ⍝ dotnet supports collection of filters on single watcher. ⎕USING←',System',(~DOTNETCORE)/'.dll' path filters←args + watcher←⎕NEW System.IO.FileSystemWatcher + watcher.Filter←,'*' + watcher.NotifyFilter←System.IO.NotifyFilters.DirectoryName + r←,watcher :If DOTNETCORE watcher←⎕NEW System.IO.FileSystemWatcher - watcher.Path←path watcher.Filters.Add¨⊂¨⊆filters - watcher.(onChanged onCreated onDeleted onRenamed)←⊂'WatchEvent' - watcher.onError←'WatchError' - watcher.IncludeSubdirectories←1 - r←watcher - :Else - r←⍬ + watcher.NotifyFilter←System.IO.NotifyFilters.(FileName+LastWrite) + r,←watcher + :Else :For filter :In ⊆filters - watcher←⎕NEW System.IO.FileSystemWatcher - watcher.Path←path - watcher.Filter←filter - watcher.(onChanged onCreated onDeleted onRenamed)←⊂'WatchEvent' - watcher.onError←'WatchError' - watcher.IncludeSubdirectories←1 - r,←watcher + watcher←⎕NEW System.IO.FileSystemWatcher + watcher.Filter←filter + watcher.NotifyFilter←System.IO.NotifyFilters.(FileName+LastWrite) + r,←watcher :EndFor - :EndIf + :EndIf + r.Path←⊂path + r.(onChanged onCreated onDeleted onRenamed)←⊂⊂'WatchEvent' + r.onError←⊂'WatchError' + r.IncludeSubdirectories←1 ∇ From 2b62f751133ba2e352b0f56e91739997208a0a4b Mon Sep 17 00:00:00 2001 From: Gilgamesh Athoraya Date: Mon, 18 Sep 2023 14:28:01 +0200 Subject: [PATCH 03/12] Don't watch typeExtensions --- StartupSession/Link/Watcher.apln | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/StartupSession/Link/Watcher.apln b/StartupSession/Link/Watcher.apln index 50fbbb86..3c46dec9 100644 --- a/StartupSession/Link/Watcher.apln +++ b/StartupSession/Link/Watcher.apln @@ -110,7 +110,7 @@ ∇ ∇ r←MakeWatcher args;filter;filters;path;watcher;⎕USING - ⍝ Return FileSystemWatcher object(s) + ⍝ Return FileSystemWatcher objects ⍝ Try .Net Core rather than Framework if non-Windows or DYALOG_NETCORE explicitly set ⍝ Creates a vector of watchers on .Net Framework to watch specific extensions. ⍝ dotnet supports collection of filters on single watcher. @@ -150,7 +150,7 @@ :Return :EndIf :If DOTNET - filters←(⊂'*.'),¨∪link.(codeExtensions,customExtensions,⊢/typeExtensions) + filters←(⊂'*.'),¨∪link.(codeExtensions,customExtensions) r←MakeWatcher link.dir filters r.EnableRaisingEvents←1 link.fsw←r From 01e7331acd7af36296e17f006aa7d503773278c7 Mon Sep 17 00:00:00 2001 From: Gilgamesh Athoraya Date: Tue, 19 Sep 2023 16:43:11 +0200 Subject: [PATCH 04/12] Handle deletion of folder, del fns linked to it --- StartupSession/Link/Notify.aplf | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/StartupSession/Link/Notify.aplf b/StartupSession/Link/Notify.aplf index 385edc21..ada246d3 100644 --- a/StartupSession/Link/Notify.aplf +++ b/StartupSession/Link/Notify.aplf @@ -80,6 +80,13 @@ :EndIf :EndIf + :If deleted + linkedpaths←⊃¨5176⌶0 + children←((⊃¨⎕NPARTS linkedpaths)∊⊂path,'/')/linkedpaths + :AndIf 0<≢children + Notify¨{'deleted'⍵}¨children + :EndIf + :If dir⍱link U.HasExtn path ⍝ must be directory or have correct extension →END⊣msg,←⊂'file extension not managed by link' :ElseIf 0=≢nsref ⋄ warn←1 ⋄ msg,←⊂'unable to find corresponding namespace' From 4935b9c096e00ebeb7a79b7000dfe631e1aedf39 Mon Sep 17 00:00:00 2001 From: Gilgamesh Athoraya Date: Tue, 19 Sep 2023 16:50:17 +0200 Subject: [PATCH 05/12] Ignore folder name when flatten --- StartupSession/Link/Notify.aplf | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/StartupSession/Link/Notify.aplf b/StartupSession/Link/Notify.aplf index ada246d3..1ea4e227 100644 --- a/StartupSession/Link/Notify.aplf +++ b/StartupSession/Link/Notify.aplf @@ -91,7 +91,7 @@ →END⊣msg,←⊂'file extension not managed by link' :ElseIf 0=≢nsref ⋄ warn←1 ⋄ msg,←⊂'unable to find corresponding namespace' →(type≢'deleted')×END ⍝ Exit if event was "deleted", else report error - :ElseIf nc=¯1 ⋄ warn←1 ⋄ →END⊣msg,←'invalid name defined by file: 'path + :ElseIf (~link.flatten∧dir)∧(nc=¯1) ⋄ warn←1 ⋄ →END⊣msg,←'invalid name defined by file: 'path :ElseIf (deleted∨~link.fastLoad)∧(nc=0) ⍝ cannot trust nc returned by DetermineAplName when opts.fastLoad warn←~deleted ⍝ link issue #235 : the delete callback provoked by ⎕SE.Link.Expunge cannot see the expunged name →END⊣msg,←⊂(1+deleted)⊃'invalid file contents' 'could not determine which object was linked to it' @@ -142,7 +142,7 @@ msg,←,'updating previously linked 'affected :ElseIf 0≠⎕NC affected ⍝ redefining existing name :AndIf curfile≢oldpath ⍝ name not bound to old file (TODO won't work for arrays) - warn←1 ⋄ name←'' ⋄ →END⊣msg,←'ignoring attempt to redefine 'affected,(0<≢curfile)/' which is linked to 'curfile + warn←~dir∧link.flatten ⋄ name←'' ⋄ →END⊣msg,←'ignoring attempt to redefine 'affected,(0<≢curfile)/' which is linked to 'curfile :EndIf :If NOTIFY U.Notify oldpath,' renamed as ',path @@ -164,8 +164,11 @@ :EndTrap msg,←'namespace rename 'oldname' → 'affected Notify¨{'changed'⍵}¨children - :Else ⋄ warn←1 ⍝ no old ns - msg,←'namespace 'oldname' not found. Loading 'affected' from 'path + :Else + :If ~link.flatten + warn←1 ⍝ no old ns + msg,←'namespace 'oldname' not found. Loading 'affected' from 'path + :EndIf :If 0<≢inFail←2⊃link U.FixFiles nsref path 1 ⍝ always overwrite msg,←' - failed to load: '(U.FmtLines inFail) :EndIf From dcb967ab69c122d1d6041f40937d49a0ae3f6ff3 Mon Sep 17 00:00:00 2001 From: Gilgamesh Athoraya Date: Tue, 19 Sep 2023 16:52:29 +0200 Subject: [PATCH 06/12] Only handle watched extensions --- StartupSession/Link/Notify.aplf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/StartupSession/Link/Notify.aplf b/StartupSession/Link/Notify.aplf index 1ea4e227..6474c627 100644 --- a/StartupSession/Link/Notify.aplf +++ b/StartupSession/Link/Notify.aplf @@ -163,7 +163,10 @@ :Else ⋄ children←0⍴⊂'' :EndTrap msg,←'namespace rename 'oldname' → 'affected - Notify¨{'changed'⍵}¨children + children←(link U.HasExtn children)/children + :If 0<≢children + Notify¨{'changed'⍵}¨children + :EndIf :Else :If ~link.flatten warn←1 ⍝ no old ns From 903cbec3e5af22f5df6dc5fed2b530dbce03f24f Mon Sep 17 00:00:00 2001 From: Gilgamesh Athoraya Date: Tue, 19 Sep 2023 16:53:09 +0200 Subject: [PATCH 07/12] Handle moving of folders within watched folder --- StartupSession/Link/Notify.aplf | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/StartupSession/Link/Notify.aplf b/StartupSession/Link/Notify.aplf index 6474c627..595fc632 100644 --- a/StartupSession/Link/Notify.aplf +++ b/StartupSession/Link/Notify.aplf @@ -116,6 +116,15 @@ :ElseIf ~curnc∊0 ¯1 ⍝ file already tied to another name (⍎curnsname)U.Untie curactname msg,←'creating 'affected' - unlinking previously linked 'curname + :ElseIf dir + :Trap 0 ⋄ children←⊃⎕NINFO⍠1⊢path,'/*' + :Else ⋄ children←0⍴⊂'' + :EndTrap + children←(link U.HasExtn children)/children + :If 0<≢children + Notify¨{'created'⍵}¨children + :EndIf + :If link.flatten ⋄ →END⊣msg,←⊂'ignoring created directory' ⋄ :EndIf :Else msg,←'creating 'affected :EndIf From 35c0ac836dd13e490d67cdd3ee3038c6ab892373 Mon Sep 17 00:00:00 2001 From: Gilgamesh Athoraya Date: Tue, 19 Sep 2023 17:03:50 +0200 Subject: [PATCH 08/12] Throttle FSW handler and queue up events --- StartupSession/Link/Watcher.apln | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/StartupSession/Link/Watcher.apln b/StartupSession/Link/Watcher.apln index 3c46dec9..b9b55244 100644 --- a/StartupSession/Link/Watcher.apln +++ b/StartupSession/Link/Watcher.apln @@ -5,7 +5,7 @@ DYALOGVERSION←1 .1+.×2↑⊃(//)'.'⎕VFI 2⊃'.'⎕WG'AplVersion' ⍝ required at ⎕FIX time - can't rely on ##.U IS180←18≤DYALOGVERSION IS181←18.1≤DYALOGVERSION - + BUFFER←⍬ ⍝ event buffer for throttling FSW events CRAWLER←0 ⍝ allow using crawler @@ -72,14 +72,27 @@ ∇ WatchEvent(obj args);ct;nargs;timers ⍝ Callback for System.IO.FileSystemWatcher instance ⍝ Passes info on to ⎕SE.Link.Notify for processing - {}2501⌶0 ⍝ Reap the thread on exit - triggers mantis 17628 + ⍝{}2501⌶0 ⍝ Reap the thread on exit - triggers mantis 17628 ⍝{}2502⌶0 ⍝ Discard parked thread - workaround mantis 17628 nargs←⊂0 ##.U.CaseText⍕args.ChangeType nargs,←⊂args.FullPath :If 0≠⎕NC⊂'args.OldFullPath' nargs,←⊂args.OldFullPath :EndIf - obj ##.Notify&nargs + BUFFER,←⊂obj nargs + THROTTLE.FireOnce←1 + ∇ + + ∇ WatchEventThrottle args;evts;types;targets + ⍝ Throttle calls to Notify and filter/re-order events + {}2502⌶0 ⍝ Discard parked thread + BUFFER←(≢evts←BUFFER)↓BUFFER + types←(⊂2 1)⊃¨evts + evts←evts[⍋'deleted' 'created' 'renamed' 'changed'⍳types] + targets←(⊂2 2)⊃¨evts + evts←evts[∪⍳⍨targets] + {##.Notify/↑⍵}&evts + ⍝ ∇ ∇ WatchError(obj args);link;msg @@ -110,7 +123,7 @@ ∇ ∇ r←MakeWatcher args;filter;filters;path;watcher;⎕USING - ⍝ Return FileSystemWatcher objects + ⍝ Return vector of FileSystemWatcher objects ⍝ Try .Net Core rather than Framework if non-Windows or DYALOG_NETCORE explicitly set ⍝ Creates a vector of watchers on .Net Framework to watch specific extensions. ⍝ dotnet supports collection of filters on single watcher. @@ -137,6 +150,13 @@ r.(onChanged onCreated onDeleted onRenamed)←⊂⊂'WatchEvent' r.onError←⊂'WatchError' r.IncludeSubdirectories←1 + r.InternalBufferSize←65536 ⍝ Max size is 64KB + :If 0=⎕NC'THROTTLE' + THROTTLE←⎕NEW⊂'Timer' + THROTTLE.FireOnce←2 + THROTTLE.Interval←200 + THROTTLE.onTimer←'WatchEventThrottle' + :EndIf ∇ From 1e420ba572ba31155256d81b9fe112beff5b0b24 Mon Sep 17 00:00:00 2001 From: Gilgamesh Athoraya Date: Tue, 14 Nov 2023 15:00:15 +0100 Subject: [PATCH 09/12] Restore stop/trace/monitor bits --- StartupSession/Link/Utils.apln | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/StartupSession/Link/Utils.apln b/StartupSession/Link/Utils.apln index 22c37e6c..de78ebcd 100644 --- a/StartupSession/Link/Utils.apln +++ b/StartupSession/Link/Utils.apln @@ -700,9 +700,9 @@ ⍝ Link 0|1 (default 1) ⍝ maintain the link to the file - link issue #155 FIX←where.⎕FIX⍠('Quiet' 1)('AllowLateBinding' 1)('FixWithErrors'force)('Link'(~0∊⍴file)) :EndIf - ⍝:If (⌊|where.⎕NC⊂name)∊3 4 ⋄ (stops trace monitor)←(where.⎕STOP name)(where.⎕TRACE name)(⊣/where.⎕MONITOR name) ⍝ link issue #148 and #129 - ⍝:Else ⋄ stops←trace←monitor←⍬ - ⍝:EndIf + :If (⌊|where.⎕NC⊂name)∊3 4 ⋄ (stops trace monitor)←(where.⎕STOP name)(where.⎕TRACE name)(⊣/where.⎕MONITOR name) ⍝ link issue #148 and #129 + :Else ⋄ stops←trace←monitor←⍬ + :EndIf ⍝ attempt to fix as named script because this is the most commly expected format :Trap 0 ⋄ names←(2 FIX src) ⍝ fn/op/script - can work from file :Else ⋄ names←0⍴⊂'' @@ -711,9 +711,9 @@ :If 1=≢names ⋄ name←⊃names ⋄ nc←where.⎕NC⊂name :Else ⋄ name←'' ⋄ nc←0 ⍝ multiple names in single file not supported :EndIf - ⍝:If ((⌊|nc)∊3 4)∧(0∨.<⊃∘⍴¨stops trace monitor) ⍝ restore stops, traces and monitor - monitor timing information will be lost - ⍝ stops where.⎕STOP name ⋄ trace where.⎕TRACE name ⋄ monitor where.⎕MONITOR name - ⍝:EndIf + :If ((⌊|nc)∊3 4)∧(0∨.<⊃∘⍴¨stops trace monitor) ⍝ restore stops, traces and monitor - monitor timing information will be lost + stops where.⎕STOP name ⋄ trace where.⎕TRACE name ⋄ monitor where.⎕MONITOR name + :EndIf :Return ⍝ named script fixed :EndIf ⍝required←11 116≡⎕DMX.(EN ENX) ⍝ 2 ⎕FIX failed because cannot read :Required file From de0c492a221ce4200581963afc2a9ed840c2cbaf Mon Sep 17 00:00:00 2001 From: Morten Kromberg Date: Sun, 2 Jun 2024 14:19:05 +0200 Subject: [PATCH 10/12] Tentative fix for disappearing functions on Git branch switch --- StartupSession/Link/Watcher.apln | 55 +++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/StartupSession/Link/Watcher.apln b/StartupSession/Link/Watcher.apln index b9b55244..f6ed8d7a 100644 --- a/StartupSession/Link/Watcher.apln +++ b/StartupSession/Link/Watcher.apln @@ -57,7 +57,6 @@ canwatch←CRAWLER∨DOTNET ⍝ must be evaluated at runtime to allow ⎕SE.Link.Test to change them ∇ - ∇ RequeuedEvent(obj event args) ⍝ Process events redirected via the timer :Select event @@ -72,27 +71,53 @@ ∇ WatchEvent(obj args);ct;nargs;timers ⍝ Callback for System.IO.FileSystemWatcher instance ⍝ Passes info on to ⎕SE.Link.Notify for processing - ⍝{}2501⌶0 ⍝ Reap the thread on exit - triggers mantis 17628 - ⍝{}2502⌶0 ⍝ Discard parked thread - workaround mantis 17628 nargs←⊂0 ##.U.CaseText⍕args.ChangeType nargs,←⊂args.FullPath :If 0≠⎕NC⊂'args.OldFullPath' nargs,←⊂args.OldFullPath :EndIf - BUFFER,←⊂obj nargs - THROTTLE.FireOnce←1 + BUFFER,←⊂obj nargs ⍝ Add event to the queue + THROTTLE.FireOnce←1 ⍝ Restart the timer ∇ - ∇ WatchEventThrottle args;evts;types;targets + ∇ HandleEventQueue args;evts;types;targets;exist;actions;m;todo;slash;tgts;order;ops;exists;renames;nex;fsw ⍝ Throttle calls to Notify and filter/re-order events - {}2502⌶0 ⍝ Discard parked thread - BUFFER←(≢evts←BUFFER)↓BUFFER - types←(⊂2 1)⊃¨evts - evts←evts[⍋'deleted' 'created' 'renamed' 'changed'⍳types] - targets←(⊂2 2)⊃¨evts - evts←evts[∪⍳⍨targets] - {##.Notify/↑⍵}&evts - ⍝ + {}2502⌶0 ⍝ Discard the parked thread that was presumably created by the incoming events + + BUFFER←(≢evts←BUFFER)↓BUFFER + ⎕←' ' + ⎕←'EventQueue original:' + ⎕← ((⍳≢evts),0 1↓↑evts) + fsw←⊃⊃evts ⍝ Actually there might be more than one but it probably doesn't matter + (actions targets)←2↑↓⍉↑2⊃¨evts + + ⍝ Eliminate "internal" git folder notifications + slash←⊃⌽(1⊃targets)∩'/\' ⍝ slash at tail end of FSW messages are "native" + :If ∨/m←∨/¨(slash,'.git',slash)∘⍷¨targets + (actions targets evts)←(~m)∘/¨actions targets evts + :EndIf + + ⍝ Separate logic for renames + ⍝ We think Git operations are never renames + :If 0≠≢renames←(m←actions∊⊂'renamed')/evts + targets←(~m)/targets + :If ~∧/m ⍝ Worried that combining renames with other logic may go badly + ##.U.Warn 'Rename batched with other operations' + :EndIf + :EndIf + + exists←⎕NEXISTS tgts←∪targets ⍝ deletions first - matters if flatten=1 + order←⍋exists,⍪(¯1*nex←~exists)×≢¨tgts ⍝ delete folders after contents, create folders before contents + ops←((+/nex),(+/exists))/'deleted' 'changed' + ⍝ renames, then deletes, then changed (Link does not distinguish between create and change) + todo←renames,fsw,∘⊂¨↓ops,⍪tgts[order] + + ⎕←'==> "todo" :' + ⎕← ((⍳≢todo),0 1↓↑todo) + + :If 0≠≢todo + {##.Notify/↑⍵}&todo + :EndIf ∇ ∇ WatchError(obj args);link;msg @@ -155,7 +180,7 @@ THROTTLE←⎕NEW⊂'Timer' THROTTLE.FireOnce←2 THROTTLE.Interval←200 - THROTTLE.onTimer←'WatchEventThrottle' + THROTTLE.onTimer←'HandleEventQueue' :EndIf ∇ From 69b3a731bd4f6cd482e3034089d621e9db3fbf29 Mon Sep 17 00:00:00 2001 From: Morten Kromberg Date: Wed, 5 Jun 2024 05:57:33 +0200 Subject: [PATCH 11/12] Implement ALWAYSREFORMAT and FSWDELAY --- StartupSession/Link/Utils.apln | 8 ++++++-- StartupSession/Link/Watcher.apln | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/StartupSession/Link/Utils.apln b/StartupSession/Link/Utils.apln index de78ebcd..10f7d89f 100644 --- a/StartupSession/Link/Utils.apln +++ b/StartupSession/Link/Utils.apln @@ -2,7 +2,8 @@ ⎕IO ⎕ML←1 1 :Section Constants - SRC_BEST←62 ⍝ ⎕ATX fact + SRC_NORMALIZED←61 ⍝ ⎕ATX fact + SRC_BEST← 62 ⍝ ⎕ATX fact ISWIN←'Win'≡3↑⊃# ⎕WG'APLVersion' DYALOGVERSION←1 .1+.×2↑⊃(//)'.'⎕VFI 2⊃'.'⎕WG'AplVersion' IS180←18.0≤DYALOGVERSION @@ -17,6 +18,9 @@ :EndIf ∇ ##.NOTIFY←'1'∊2 ⎕NQ '.' 'GetEnvironment' 'LINK\NOTIFY' + ##.ALWAYSREFORMAT←'1'∊2 ⎕NQ '.' 'GetEnvironment' 'LINK\ALWAYSREFORMAT' + ##.FSWDELAY←{⍵+200×⍵=0}⊃2⊃⎕VFI 2 ⎕NQ '.' 'GetEnvironment' 'LINK\FSWDELAY' + LASTFIX←⍬ ⍝ remember last onFix event :EndSection @@ -660,7 +664,7 @@ :EndTrap :CaseList 3.1 3.2 4.1 4.2 ⍝ tradfn/dfn/tradop/dop - v18.0 cannot get source of functions "as typed" src←⎕NULL - :If IS181 ⋄ :Trap 11 ⋄ src←SRC_BEST ns.⎕ATX name ⋄ :EndTrap ⋄ :EndIf ⍝ ⎕ATX returns ⎕NULL if source not available - ⎕ATX errors if name doesn't exist + :If IS181 ⋄ :Trap 11 ⋄ src←(SRC_BEST SRC_NORMALIZED)[1+##.ALWAYSREFORMAT] ns.⎕ATX name ⋄ :EndTrap ⋄ :EndIf ⍝ ⎕ATX returns ⎕NULL if source not available - ⎕ATX errors if name doesn't exist :If src≡⎕NULL ⋄ src←ns.⎕NR name ⋄ :EndIf ⍝ de-tokenised source - not "as typed" - ⎕NR never errors :CaseList 9.1 9.4 9.5 ⋄ src←GetRefSource ns⍎name ⍝ ns/class/interface :Else ⋄ src←'Cannot get source of ',(⍕ns),'.',name,': Invalid name class (',(⍕nc),')' diff --git a/StartupSession/Link/Watcher.apln b/StartupSession/Link/Watcher.apln index f6ed8d7a..ecf343ee 100644 --- a/StartupSession/Link/Watcher.apln +++ b/StartupSession/Link/Watcher.apln @@ -179,7 +179,7 @@ :If 0=⎕NC'THROTTLE' THROTTLE←⎕NEW⊂'Timer' THROTTLE.FireOnce←2 - THROTTLE.Interval←200 + THROTTLE.Interval←##.FSWDELAY THROTTLE.onTimer←'HandleEventQueue' :EndIf ∇ From affb188249567669c699852e851ff4114398ece9 Mon Sep 17 00:00:00 2001 From: Morten Kromberg Date: Wed, 5 Jun 2024 07:26:37 +0200 Subject: [PATCH 12/12] Make HandleEventQueue output depend on DEBUG --- StartupSession/Link/Watcher.apln | 36 ++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/StartupSession/Link/Watcher.apln b/StartupSession/Link/Watcher.apln index ecf343ee..ef92e5d2 100644 --- a/StartupSession/Link/Watcher.apln +++ b/StartupSession/Link/Watcher.apln @@ -82,38 +82,42 @@ ∇ HandleEventQueue args;evts;types;targets;exist;actions;m;todo;slash;tgts;order;ops;exists;renames;nex;fsw ⍝ Throttle calls to Notify and filter/re-order events - {}2502⌶0 ⍝ Discard the parked thread that was presumably created by the incoming events + {}2502⌶0 ⍝ Discard the parked thread that was presumably created by the incoming event - BUFFER←(≢evts←BUFFER)↓BUFFER - ⎕←' ' - ⎕←'EventQueue original:' - ⎕← ((⍳≢evts),0 1↓↑evts) + BUFFER←(≢evts←BUFFER)↓BUFFER + :If ##.DEBUG + ⎕←' ' + ⎕←'EventQueue original:' + ⎕←((⍳≢evts),0 1↓↑evts) + :EndIf fsw←⊃⊃evts ⍝ Actually there might be more than one but it probably doesn't matter - (actions targets)←2↑↓⍉↑2⊃¨evts + (actions targets)←2↑↓⍉↑2⊃¨evts ⍝ Eliminate "internal" git folder notifications slash←⊃⌽(1⊃targets)∩'/\' ⍝ slash at tail end of FSW messages are "native" - :If ∨/m←∨/¨(slash,'.git',slash)∘⍷¨targets + :If ∨/m←∨/¨(slash,'.git',slash)∘⍷¨targets (actions targets evts)←(~m)∘/¨actions targets evts :EndIf - ⍝ Separate logic for renames + ⍝ Separate logic for renames ⍝ We think Git operations are never renames :If 0≠≢renames←(m←actions∊⊂'renamed')/evts - targets←(~m)/targets + targets←(~m)/targets :If ~∧/m ⍝ Worried that combining renames with other logic may go badly - ##.U.Warn 'Rename batched with other operations' + ##.U.Warn'Rename batched with other operations' :EndIf - :EndIf - + :EndIf + exists←⎕NEXISTS tgts←∪targets ⍝ deletions first - matters if flatten=1 order←⍋exists,⍪(¯1*nex←~exists)×≢¨tgts ⍝ delete folders after contents, create folders before contents ops←((+/nex),(+/exists))/'deleted' 'changed' - ⍝ renames, then deletes, then changed (Link does not distinguish between create and change) - todo←renames,fsw,∘⊂¨↓ops,⍪tgts[order] + ⍝ renames, then deletes, then changed (Link does not distinguish between create and change) + todo←renames,fsw,∘⊂¨↓ops,⍪tgts[order] - ⎕←'==> "todo" :' - ⎕← ((⍳≢todo),0 1↓↑todo) + :If ##.DEBUG + ⎕←'==> "todo" :' + ⎕←((⍳≢todo),0 1↓↑todo) + :EndIf :If 0≠≢todo {##.Notify/↑⍵}&todo