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 11 forks source link

link with flatten: getFilename hook called when new file is added to a linked folder, but with wrong filename in args #536

Open e9gille opened 1 year ago

e9gille commented 1 year ago

The intent of the getFilename hook is to provide the developer with a way to specify and override the filename for a given apl object. At the moment this hook is also invoked when there is a new file created in the filesystem. Unfortunately the filename provided into the hook (the 3rd item) doesn't match the actual path where the file was created (the first time it is invoked, see below repro) if the -flatten option is used.

I would like to potentially override the directory that the file is created in when a new object is created in the session, but not move a file that was placed in the filesystem. It would be good to be able to tell the difference (was this triggered because of a new item in session or filesystem), but at the very least, if the filename was correct I could check if it exists.

To Reproduce )clear clear ws 3⎕NDELETE 'test'
3⎕mkdir'test/sub'
fileHandler←{''⊣⎕←⍵}
]link.create -flatten -getfilename=#.fileHandler #.test ./test Linked: #.test ←→ /Users/gil/test (⊂'r←foo' 'r←42')⎕NPUT 'test/sub/foo.aplf'
getFilename [#.test ←→ /Users/gil/test] /Users/gil/test/foo.aplf #.test.foo 3.1 #.test.foo getFilename [#.test ←→ /Users/gil/test] /Users/gil/test/sub/foo.aplf #.test.foo 3.1 #.test.foo getFilename [#.test ←→ /Users/gil/test] /Users/gil/test/sub/foo.aplf #.test.foo 3.1 #.test.foo getFilename [#.test ←→ /Users/gil/test] /Users/gil/test/sub/foo.aplf #.test.foo 3.1 #.test.foo getFilename [#.test ←→ /Users/gil/test] /Users/gil/test/sub/foo.aplf #.test.foo 3.1 #.test.foo getFilename [#.test ←→ /Users/gil/test] /Users/gil/test/sub/foo.aplf #.test.foo 3.1 #.test.foo getFilename [#.test ←→ /Users/gil/test] /Users/gil/test/sub/foo.aplf #.test.foo 3.1 #.test.foo getFilename [#.test ←→ /Users/gil/test] /Users/gil/test/sub/foo.aplf #.test.foo 3.1 #.test.foo getFilename [#.test ←→ /Users/gil/test] /Users/gil/test/sub/foo.aplf #.test.foo 3.1 #.test.foo getFilename [#.test ←→ /Users/gil/test] /Users/gil/test/sub/foo.aplf #.test.foo 3.1 #.test.foo getFilename [#.test ←→ /Users/gil/test] /Users/gil/test/sub/foo.aplf #.test.foo 3.1 #.test.foo getFilename [#.test ←→ /Users/gil/test] /Users/gil/test/sub/foo.aplf #.test.foo 3.1 #.test.foo

Expected behaviour The filename should be correct on the first invokation, like it is in the following.

Desktop (please complete the following information): IDE: Version: 4.4.3726 Electron: 13.6.9 Chrome: 91.0.4472.164 Node: 14.16.0 Platform: MacIntel ⎕SE.Link.Version: 3.0.19