Dyalog / link

Source code for Link – the built-in component that enables the use of text files as the primary storage mechanism for APL source code
https://dyalog.github.io/link
MIT License
19 stars 10 forks source link

Loss of function if delete+create events processed out of order #487

Closed mkromberg closed 1 year ago

mkromberg commented 2 years ago

If a source file for a function (or any other object) is deleted and re-created in very quick succession, and the event callbacks run in the wrong order, then the workspace is updated but the function is immediately deleted.

The proposed fix is to verify whether the file exists during processing of a "deleted" event, and ignore it if the file exists at that point in time.

xelxebar commented 2 years ago

@mkromberg Currently running with the patch below you provided:

--- a/opt/mdyalog/18.2/64/unicode/StartupSession/Link/Notify.aplf   2022-06-29 17:10:20.589403401 +0900
+++ b/opt/mdyalog/18.2/64/unicode/StartupSession/Link/Notify.aplf   2022-06-29 16:57:26.006076009 +0900
@@ -178,6 +178,8 @@
          :Case 'deleted'
              :If 0=⎕NC affected  ⍝ object didn't exist
                  msg,←'not found: 'affected
+             :ElseIf ⎕NEXISTS curfile  ⍝ file still exists - don't expunge
+                 name←'' ⋄ →END⊣msg,←'not expunging 'affected' because 'curfile 'still exists'
              :ElseIf (0<≢curfile)∧(path≢curfile)  ⍝ name tied to another file - don't expunge
                  name←'' ⋄ →END⊣msg,←'not expunging 'affected' linked to 'curfile
              :ElseIf (~curnc∊0 ¯1)∧(curname≢affected)     ⍝ a different file was tied to a name